Getting information about a process
To get information about a process, we need access to the Info
object of the process. This is available through a ProcessHandle
. We use a call to the handle.info()
method to return it.
The Info
interface defines query methods that deliver information about the process. These are:
command()
returns anOptional<String>
containing the command that was used to start the processarguments()
returns anOptional<String[]>
that contains the arguments that were used on the command-line after the command to start the processcommandLine()
returns anOptional<String>
that contains the whole command-linestartInstant()
returns anOptional<Instant>
, which essentially represents the time the process was startedtotalCpuDuration()
returns anOptional<Duration>
, which represents the CPU time used by the process since it was starteduser()
returns anOptional<String>
that holds the name of the user the process belongs to
The values returned...