User Tools

Site Tools


en:code:core:processhandle

ProcessHandle

This object represents a running process.

Functions

ProcessHandle

Constructor function.

Syntax

var myObject = new ProcessHandle();
var myObject = new ProcessHandle(otherProcessHandle);
var myObject = new ProcessHandle(processId);

Arguments

  1. otherProcessHandle - (ProcessHandle) other ProcessHandle to copy
  2. processId - (integer) process identifier to manage

Exceptions

  • (ParameterTypeError) incorrect parameter type
  • (ParameterCountError) incorrect parameter count

Example

Create a ProcessHandle representing an invalid process.

var myObject = new ProcessHandle();

Create a ProcessHandle representing a copy of otherProcessHandle.

var myObject = new ProcessHandle(otherProcessHandle);

Create a ProcessHandle linked to the process id 1337.

var myObject = new ProcessHandle(1337);

Methods

clone

Returns a copy of this ProcessHandle.

Syntax

myObject.clone();

Returns

  • (ProcessHandle) a copy of this ProcessHandle

Example

var copyOfMyObject = myObject.clone();

equals

Returns true if this ProcessHandle and another are referencing the same process.

Syntax

myObject.equals(other);

Arguments

  1. other - (ProcessHandle) another ProcessHandle

Returns

  • (bool) true if other is referencing the same process

Example

if(myFirstObject.equals(mySecondObject))
	//Do something

toString

Returns a string representing this ProcessHandle.

Syntax

myObject.toString();

Returns

  • (string) a string representing this ProcessHandle

Example

Console.print(myObject.toString());

Notes

This method is automatically called when trying to convert a ProcessHandle to a string.

id

Returns the process id.

Syntax

myObject.id();

Returns

  • (integer) the process id

kill

Try to kill the process.

Syntax

myObject.kill(killMode, timeout);

Arguments

  1. killMode - (KillMode) the kill mode to use
  2. timeout - (integer) the timeout in milliseconds to wait when using GracefulThenForceful

Returns

  • (boolean) true if the process was killed

isRunning

Returns true if the process is currently running.

Syntax

myObject.isRunning();

Returns

  • (boolean) true if the process is currently running

command

Returns the command that was used to start this process.

Syntax

myObject.command();

Returns

  • (string) the command that was used to start this process

Exceptions

  • (OpenProcessError) unable to open the process (Windows)
  • (GetModuleFilenameError) unable to get the module filename (Windows)
  • (GetProcessError) unable to get the process command (Linux)

priority

Returns the priority of this process.

Syntax

myObject.priority();

Returns

Exceptions

  • (OpenProcessError) unable to open the process (Windows)
  • (GetPriorityClassError) unable to get priority class (Windows)
  • (OperatingSystemError) this is not available on this operating system (Linux)

Notes

This method only works on Windows, because Linux doesn't have any concept of process priority.

Enumerations

KillMode

Policy to use when trying to kill a process.

Values

  1. Graceful: Linux: send a SIGTERM signal Windows: close all windows owned by this process
  2. Forceful: Linux: send a SIGKILL signal Windows: use TerminateProcess to kill this process
  3. GracefulThenForceful: try to kill the process using the graceful technique, wait for timeout and kill it using the forceful technique

Priority

A process priority.

Values

  1. AboveNormal: above normal
  2. BelowNormal: below normal
  3. High: high
  4. Idle: idle
  5. Normal: normal
  6. Realtime: realtime
en/code/core/processhandle.txt · Last modified: 2021/02/13 11:23 by 127.0.0.1