Process
| Modifier and Type | Class and Description |
|---|---|
| private static class | |
| pack-priv static class | ProcessHandleImpl.
Implementation of ProcessHandle.Info. |
| Modifier and Type | Field and Description |
|---|---|
| private static final ConcurrentMap | completions
Map of pids to ExitCompletions. |
| private static final ProcessHandleImpl | current
Cache the ProcessHandle of this process. |
| private static final int | NOT_A_CHILD
Return value from waitForProcessExit0 indicating the process is not a child. |
| private final long | pid
The pid of this ProcessHandle. |
| private static final Executor | processReaperExecutor
The thread pool of "process reaper" daemon threads. |
| private static final long | REAPER_DEFAULT_STACKSIZE
Default size of stack for reaper processes. |
| private final long | startTime
The start time of this process. |
| private static final long | |
| private static final long |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public Stream | children()
Implements java. Returns a snapshot of the current direct children of the process. |
| pack-priv static Stream | Returns: a stream of ProcessHandlesthe pid of the process for which to find the children;
0 for all processes pid)Returns a Stream of the children of a process or all processes. |
| public int | compareTo(ProcessHandle other)
Implements java. Compares this ProcessHandle with the specified ProcessHandle for order. |
| pack-priv static CompletableFuture | completion(long pid, boolean
true if the exit value should be reaped shouldReap)Returns a CompletableFuture that completes with process exit status when the process completes. |
| public static ProcessHandleImpl | Returns: The ProcessHandle for the OS process.Hides java. Returns the ProcessHandle for the current native process. |
| public Stream | descendants()
Implements java. Returns a snapshot of the descendants of the process. |
| public boolean | |
| private static native boolean | Returns: true if the process was signaled without error; false otherwiseprocess id to kill pid, long the start time of the process startTime, boolean true to forcibly terminate (SIGKILL vs SIGTERM) forcibly)Signal the process to terminate. |
| public boolean | destroyForcibly()
Implements java. Requests the process to be killed forcibly. |
| pack-priv boolean | destroyProcess(boolean
true if the process should be terminated forcibly;
else false for a normal terminationDestroy the process for this ProcessHandle. |
| public boolean | equals(Object obj)
Overrides java. Implements java. Returns |
| pack-priv static Optional | Returns: The ProcessHandle for the pid if the process is alive; ornull if the process ID does not exist in the native system.the native process identifier pid)Returns a ProcessHandle for an existing native process. |
| private static native long | |
| pack-priv static ProcessHandleImpl | Returns: a ProcessHandle corresponding to an existing Process instanceof the known to exist process pid)Returns a ProcessHandle for an existing native process known to be alive. |
| private static native int | Returns: if greater than or equal to zero is the number of pids in the array; if greater than the length of the arrays, the arrays are too smallif pid, long[] pid equals zero, then all known processes are returned;
otherwise only direct child process pids are returnedan allocated long array to receive the pids pids, long[] an allocated long array to receive the parent pids; may be null ppids, long[] an allocated long array to receive the child start times; may be null starttimes)Returns the number of pids filled in to the array. |
| public int | hashCode()
Overrides java. Implements java. Returns a hash code value for this ProcessHandle. |
| public ProcessHandle. | |
| private static native void | |
| private static Executor | |
| public boolean | Returns: true if the process represented by this
ProcessHandle object has not yet terminated.Implements java. Tests whether the process represented by this |
| private static native long | Returns: the start time in milliseconds since 1970, 0 if the start time cannot be determined, -1 if the pid does not exist.the pid to check pid)Returns the process start time depending on whether the pid is alive. |
| public CompletableFuture | onExit()
Implements java. Returns a |
| public Optional | Returns: a ProcessHandle of the parent process;null is returned
if the child process does not have a parentImplements java. Returns a ProcessHandle for the parent process. |
| private static native long | Returns: the parent of the native pid; if any, otherwise -1the process id pid, long the startTime of the process startTime)Returns the parent of the native pid argument. |
| public long | Returns: the native process IDImplements java. Returns the native process ID.
A |
| public boolean | supportsNormalTermination()
Implements java. Returns |
| private static void | |
| public String | |
| private static native int | Returns: the value or -1 if an error occursthe processId pid, boolean if true, the value is retrieved,
else return the value and leave the process waitable reapvalue)Wait for the process to exit, return the value. |
| completions | back to summary |
|---|---|
| private static final ConcurrentMap<Long, ProcessHandleImpl. Map of pids to ExitCompletions. | |
| current | back to summary |
|---|---|
| private static final ProcessHandleImpl current Cache the ProcessHandle of this process. | |
| NOT_A_CHILD | back to summary |
|---|---|
| private static final int NOT_A_CHILD Return value from waitForProcessExit0 indicating the process is not a child. | |
| pid | back to summary |
|---|---|
| private final long pid The pid of this ProcessHandle. | |
| processReaperExecutor | back to summary |
|---|---|
| private static final Executor processReaperExecutor The thread pool of "process reaper" daemon threads. | |
| REAPER_DEFAULT_STACKSIZE | back to summary |
|---|---|
| private static final long REAPER_DEFAULT_STACKSIZE Default size of stack for reaper processes. | |
| startTime | back to summary |
|---|---|
| private final long startTime The start time of this process. If STARTTIME_ANY, the start time of the process is not available from the os. If greater than zero, the start time of the process. | |
| STARTTIME_ANY | back to summary |
|---|---|
| private static final long STARTTIME_ANY | |
| STARTTIME_PROCESS_UNKNOWN | back to summary |
|---|---|
| private static final long STARTTIME_PROCESS_UNKNOWN | |
| ProcessHandleImpl | back to summary |
|---|---|
| private ProcessHandleImpl(long pid, long startTime) Private constructor. Instances are created by the
| |
| children | back to summary |
|---|---|
| public Stream Implements java. Doc from java. Returns a snapshot of the current direct children of the process.
The
Note that processes are created and terminate asynchronously.
There is no guarantee that a process is
| |
| children | back to summary |
|---|---|
| pack-priv static Stream Returns a Stream of the children of a process or all processes.
| |
| compareTo | back to summary |
|---|---|
| public int compareTo(ProcessHandle other) Implements java. Doc from java. Compares this ProcessHandle with the specified ProcessHandle for order.
The order is not specified, but is consistent with
| |
| completion | back to summary |
|---|---|
| pack-priv static CompletableFuture Returns a CompletableFuture that completes with process exit status when the process completes.
| |
| current | back to summary |
|---|---|
| public static ProcessHandleImpl current() Hides java. Returns the ProcessHandle for the current native process.
| |
| descendants | back to summary |
|---|---|
| public Stream Implements java. Doc from java. Returns a snapshot of the descendants of the process.
The descendants of a process are the children of the process
plus the descendants of those children, recursively.
Typically, a process that is
Note that processes are created and terminate asynchronously.
There is no guarantee that a process is
| |
| destroy | back to summary |
|---|---|
| public boolean destroy() Implements java. Doc from java. Requests the process to be killed.
Whether the process represented by this
The Note The process may not terminate immediately.
For example,
| |
| destroy0 | back to summary |
|---|---|
| private static native boolean destroy0(long pid, long startTime, boolean forcibly) Signal the process to terminate. The process is signaled only if its start time matches the known start time.
| |
| destroyForcibly | back to summary |
|---|---|
| public boolean destroyForcibly() Implements java. Doc from java. Requests the process to be killed forcibly.
The process represented by this
The Note The process may not terminate immediately.
For example,
| |
| destroyProcess | back to summary |
|---|---|
| pack-priv boolean destroyProcess(boolean force) Destroy the process for this ProcessHandle. The native code checks the start time before sending the termination request.
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Implements java. Doc from java. Returns
| |
| get | back to summary |
|---|---|
| pack-priv static Optional Returns a ProcessHandle for an existing native process.
| |
| getCurrentPid0 | back to summary |
|---|---|
| private static native long getCurrentPid0() Return the pid of the current process.
| |
| getInternal | back to summary |
|---|---|
| pack-priv static ProcessHandleImpl getInternal(long pid) Returns a ProcessHandle for an existing native process known to be alive. The startTime of the process is retrieved and stored in the ProcessHandle. It does not perform a security check since it is called from ProcessImpl.
| |
| getProcessPids0 | back to summary |
|---|---|
| private static native int getProcessPids0(long pid, long[] pids, long[] ppids, long[] starttimes) Returns the number of pids filled in to the array.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Implements java. Doc from java. Returns a hash code value for this ProcessHandle.
The hashcode value follows the general contract for
| |
| info | back to summary |
|---|---|
| public ProcessHandle. Implements java. Doc from java. Returns a snapshot of information about the process. A
| |
| initNative | back to summary |
|---|---|
| private static native void initNative() | |
| initReaper | back to summary |
|---|---|
| private static Executor initReaper() | |
| isAlive | back to summary |
|---|---|
| public boolean isAlive() Implements java. Tests whether the process represented by this
| |
| isAlive0 | back to summary |
|---|---|
| private static native long isAlive0(long pid) Returns the process start time depending on whether the pid is alive. This must not reap the exitValue.
| |
| onExit | back to summary |
|---|---|
| public CompletableFuture Implements java. Doc from java. Returns a
Calling
| |
| parent | back to summary |
|---|---|
| public Optional Implements java. Returns a ProcessHandle for the parent process.
| |
| parent0 | back to summary |
|---|---|
| private static native long parent0(long pid, long startTime) Returns the parent of the native pid argument.
| |
| pid | back to summary |
|---|---|
| public long pid() Implements java. Returns the native process ID.
A
| |
| supportsNormalTermination | back to summary |
|---|---|
| public boolean supportsNormalTermination() Implements java. Doc from java. Returns
| |
| swap | back to summary |
|---|---|
| private static void swap(long[] array, int x, int y) | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non-
| |
| waitForProcessExit0 | back to summary |
|---|---|
| private static native int waitForProcessExit0(long pid, boolean reapvalue) Wait for the process to exit, return the value. Conditionally reap the value if requested
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final boolean |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| isReaping | back to summary |
|---|---|
| pack-priv final boolean isReaping | |
| ExitCompletion | back to summary |
|---|---|
| pack-priv ExitCompletion(boolean isReaping) | |
null or -1 is stored.
The accessor methods return null if the value is not available.
| Modifier and Type | Field and Description |
|---|---|
| pack-priv String[] | |
| pack-priv String | |
| pack-priv String | |
| pack-priv long | |
| pack-priv long | |
| pack-priv String |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public Optional | arguments()
Implements java. Returns an array of Strings of the arguments of the process. |
| public Optional | command()
Implements java. Returns the executable pathname of the process. |
| public Optional | commandLine()
Implements java. Returns the command line of the process. |
| public static ProcessHandle. | Returns: ProcessHandle.Info non-null; individual fields may be null or -1 if not available.the native process identifier pid, long the startTime of the process being queried startTime)Returns the Info object with the fields from the process. |
| private native void | info0(long
of the native process pid)Fill in this Info instance with information about the native process. |
| private static native void | |
| public Optional | startInstant()
Implements java. Returns the start time of the process. |
| public String | |
| public Optional | totalCpuDuration()
Implements java. Returns the total cputime accumulated of the process. |
| public Optional |
| arguments | back to summary |
|---|---|
| pack-priv String[] arguments | |
| command | back to summary |
|---|---|
| pack-priv String command | |
| commandLine | back to summary |
|---|---|
| pack-priv String commandLine | |
| startTime | back to summary |
|---|---|
| pack-priv long startTime | |
| totalTime | back to summary |
|---|---|
| pack-priv long totalTime | |
| user | back to summary |
|---|---|
| pack-priv String user | |
| Info | back to summary |
|---|---|
| pack-priv Info() | |
| arguments | back to summary |
|---|---|
| public Optional Implements java. Doc from java. Returns an array of Strings of the arguments of the process.
| |
| command | back to summary |
|---|---|
| public Optional Implements java. Doc from java. Returns the executable pathname of the process.
| |
| commandLine | back to summary |
|---|---|
| public Optional Implements java. Doc from java. Returns the command line of the process.
If
| |
| info | back to summary |
|---|---|
| public static ProcessHandle. Returns the Info object with the fields from the process. Whatever fields are provided by native are returned. If the startTime of the process does not match the provided startTime then an empty Info is returned.
| |
| info0 | back to summary |
|---|---|
| private native void info0(long pid) Fill in this Info instance with information about the native process. If values are not available the native code does not modify the field.
| |
| initIDs | back to summary |
|---|---|
| private static native void initIDs() Initialization of JNI fieldIDs. | |
| startInstant | back to summary |
|---|---|
| public Optional Implements java. Doc from java. Returns the start time of the process.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non-
| |
| totalCpuDuration | back to summary |
|---|---|
| public Optional Implements java. Doc from java. Returns the total cputime accumulated of the process.
| |
| user | back to summary |
|---|---|
| public Optional Implements java. Doc from java. Return the user of the process.
| |