Package org.jvnet.winp
Class WinProcess
java.lang.Object
org.jvnet.winp.WinProcess
Represents a Windows process.
On Windows, there are several system pseudo-processes, for which many of the getter invocations would fail. This includes "system idle process" (which always seem to have PID=0) and "System" (which always seem to have PID=4)
- Author:
- Kohsuke Kawaguchi
-
Constructor Summary
ConstructorsConstructorDescriptionWinProcess(int pid) Wraps a process ID.WinProcess(Process proc) WrapsProcessintoWinProcess. -
Method Summary
Modifier and TypeMethodDescriptionstatic Iterable<WinProcess>all()Enumerates all the processes in the system.static voidElevates the security privilege of this process so that we can obtain information about processes owned by other users.Gets the command line given to this process.Gets the environment variables of this process.intgetPid()Gets the process ID.booleanbooleanvoidkill()voidKills this process and all the descendant processes that this process launched.booleanSends Ctrl+C to the process.voidsetPriority(int priority) Sets the execution priority of this thread.toString()
-
Constructor Details
-
WinProcess
public WinProcess(int pid) Wraps a process ID. -
WinProcess
WrapsProcessintoWinProcess.
-
-
Method Details
-
toString
-
getPid
public int getPid()Gets the process ID. -
killRecursively
public void killRecursively()Kills this process and all the descendant processes that this process launched. -
kill
public void kill() -
sendCtrlC
Sends Ctrl+C to the process. Due to the Windows platform specifics, this execution will spawn a separate thread to deliver the signal. This process is expected to be executed within a 5-second timeout.- Returns:
trueif the signal was delivered successfully- Throws:
WinpException- Execution error
-
isRunning
public boolean isRunning() -
isCriticalProcess
public boolean isCriticalProcess() -
setPriority
public void setPriority(int priority) Sets the execution priority of this thread.- Parameters:
priority- One of the values fromPriority.
-
getCommandLine
Gets the command line given to this process. On Windows, a command line is a single string, unlike Unix. The tokenization semantics is up to applications.- Throws:
WinpException- If Winp fails to obtain the command line. The process may be dead or there is not enough security privileges.
-
getEnvironmentVariables
Gets the environment variables of this process.The returned map has a case-insensitive comparison semantics.
- Returns:
- Never null.
- Throws:
WinpException- If Winp fails to obtain the environment variables. The process may be dead or there is not enough security privileges.
-
all
Enumerates all the processes in the system.- Returns:
- Never null.
- Throws:
WinpException- If the enumeration fails.
-
enableDebugPrivilege
public static void enableDebugPrivilege()Elevates the security privilege of this process so that we can obtain information about processes owned by other users.Otherwise some of the getter methods may fail with
WinpExceptiondue to access denied error.
-