SilkJS builtin process object.
The builtin/process object provides constants and methods to directly access the underlying operating system's process-oriented functions.
var process = require('builtin/process');
Operating system man pages
Returns string version of last OS error.
var message = process.error();
Returns real user ID (uid) of calling process
var uid = process.getuid();
Set real user ID (uid) of calling process
var status = process.getuid(newId);
Returns real group ID (gid) of calling process
var gid = process.getgid();
Set real group ID (gid) of calling process
var status = process.getgid(newId);
Get user information from the system user database
var info = process.getpwnam(login);
The returned object has the following fields:
name: login name
passwd: the user's password (may not be reliable if using shadow, etc.)
uid: the user's user ID
gid: the user's group ID
gecos: "user information"
dir: user's home directory
shell: user's shell
Get user information from the system user database
var info = process.getpwnam(uid);
The returned object has the following fields:
name: login name
passwd: the user's password (may not be reliable if using shadow, etc.)
uid: the user's user ID
gid: the user's group ID
gecos: "user information"
dir: user's home directory
shell: user's shell
Get group information from the system user database
var info = process.getgrnam(name);
The returned object has the following fields:
name: group name
passwd: the group's password (may not be reliable if using shadow, etc.)
gid: the user's group ID
mem: array of member names (strings)
Get group information from the system user database
var info = process.getgrgid(gid);
The returned object has the following fields:
name: group name
passwd: the group's password (may not be reliable if using shadow, etc.)
gid: the user's group ID
mem: array of member names (strings)
var success = process.kill(pid);
Send the SIGKILL signal to the specified process (by pid).
var my_pid = process.getpid();
Returns the pid of the current process.
var pid = process.fork();
Create a new process.
Fork() causes creation of a new process. The new process (child process) is an exact copy of the calling process (parent process) except for the following:
The child process has a unique process ID.
The child process has a different parent process ID (i.e., the process ID of the parent process).
The child process has its own copy of the parent's descriptors. These descriptors reference the same underlying objects, so that, for instance, file pointers in file objects are shared between the child and the parent, so that an lseek(2) on a descriptor in the child process can affect a subsequent read or write by the parent. This descriptor copying is also used by the shell to establish standard input and output for newly created processes as well as to set up pipes.
The child processes resource utilizations are set to 0; see the man page for setrlimit(2).
process.exit(status);
Terminate the current process or program, returning status to the parent or shell.
process.sleep(seconds);
Suspend execution of the current process for specified number of seconds.
process.usleep(microseconds);
Suspend execution of the current process for specified number of microseconds.
var o = process.wait();
var o = process.wait(poll)
Wait for process termination.
This function suspends execution of its calling process until one of its child processes terminates. The function returns an object of the form:
process.exit()
var output = process.exec(command_line);
Execute a Unix command, returning the output of the command (it's stdout) as a JavaScript string.
This function calls popen() with the specified command line and reads its output until end of file. Under the hood, a fork() and exec() is performed which is not particularly fast. Still it can be useful to execute shell commands.
var result = process.exec_result);
Returns the exit code of the last process.exec() call.
NOTE: The value is the low-order 8 bits of the argument the program run by exec() passed to _exit(2) or exit(3).
var env = process.env();
Get a hash of key/value pairs representing the environment of the calling process.
Typical kinds of environment variables you'll see returned by this function are:
HOME - user's home directory.
PATH - the sequence of directories, separated by colons, searched for command execution.
...
var o = process.rusage();
Get resource usage information for current process.
The object returned is of the form:
var username = process.getlogin();
Get a string containing the name of the user logged in on the controlling terminal of the process.