Node:Processes, Next:, Previous:Runtime Environment, Up:POSIX



38.7 Processes

chdir str Scheme Procedure
scm_chdir (str) C Function
Change the current working directory to path. The return value is unspecified.

getcwd Scheme Procedure
scm_getcwd () C Function
Return the name of the current working directory.

umask [mode] Scheme Procedure
scm_umask (mode) C Function
If mode is omitted, returns a decimal number representing the current file creation mask. Otherwise the file creation mask is set to mode and the previous value is returned.

E.g., (umask #o022) sets the mask to octal 22, decimal 18.

chroot path Scheme Procedure
scm_chroot (path) C Function
Change the root directory to that specified in path. This directory will be used for path names beginning with /. The root directory is inherited by all children of the current process. Only the superuser may change the root directory.

getpid Scheme Procedure
scm_getpid () C Function
Return an integer representing the current process ID.

getgroups Scheme Procedure
scm_getgroups () C Function
Return a vector of integers representing the current supplementary group IDs.

getppid Scheme Procedure
scm_getppid () C Function
Return an integer representing the process ID of the parent process.

getuid Scheme Procedure
scm_getuid () C Function
Return an integer representing the current real user ID.

getgid Scheme Procedure
scm_getgid () C Function
Return an integer representing the current real group ID.

geteuid Scheme Procedure
scm_geteuid () C Function
Return an integer representing the current effective user ID. If the system does not support effective IDs, then the real ID is returned. (feature? 'EIDs) reports whether the system supports effective IDs.

getegid Scheme Procedure
scm_getegid () C Function
Return an integer representing the current effective group ID. If the system does not support effective IDs, then the real ID is returned. (feature? 'EIDs) reports whether the system supports effective IDs.

setuid id Scheme Procedure
scm_setuid (id) C Function
Sets both the real and effective user IDs to the integer id, provided the process has appropriate privileges. The return value is unspecified.

setgid id Scheme Procedure
scm_setgid (id) C Function
Sets both the real and effective group IDs to the integer id, provided the process has appropriate privileges. The return value is unspecified.

seteuid id Scheme Procedure
scm_seteuid (id) C Function
Sets the effective user ID to the integer id, provided the process has appropriate privileges. If effective IDs are not supported, the real ID is set instead - (feature? 'EIDs) reports whether the system supports effective IDs. The return value is unspecified.

setegid id Scheme Procedure
scm_setegid (id) C Function
Sets the effective group ID to the integer id, provided the process has appropriate privileges. If effective IDs are not supported, the real ID is set instead - (feature? 'EIDs) reports whether the system supports effective IDs. The return value is unspecified.

getpgrp Scheme Procedure
scm_getpgrp () C Function
Return an integer representing the current process group ID. This is the POSIX definition, not BSD.

setpgid pid pgid Scheme Procedure
scm_setpgid (pid, pgid) C Function
Move the process pid into the process group pgid. pid or pgid must be integers: they can be zero to indicate the ID of the current process. Fails on systems that do not support job control. The return value is unspecified.

setsid Scheme Procedure
scm_setsid () C Function
Creates a new session. The current process becomes the session leader and is put in a new process group. The process will be detached from its controlling terminal if it has one. The return value is an integer representing the new process group ID.

waitpid pid [options] Scheme Procedure
scm_waitpid (pid, options) C Function
This procedure collects status information from a child process which has terminated or (optionally) stopped. Normally it will suspend the calling process until this can be done. If more than one child process is eligible then one will be chosen by the operating system.

The value of pid determines the behaviour:

pid greater than 0
Request status information from the specified child process.
pid equal to -1 or WAIT_ANY
Request status information for any child process.
pid equal to 0 or WAIT_MYPGRP
Request status information for any child process in the current process group.
pid less than -1
Request status information for any child process whose process group ID is -PID.

The options argument, if supplied, should be the bitwise OR of the values of zero or more of the following variables:

WNOHANG Variable
Return immediately even if there are no child processes to be collected.

WUNTRACED Variable
Report status information for stopped processes as well as terminated processes.

The return value is a pair containing:

  1. The process ID of the child process, or 0 if WNOHANG was specified and no process was collected.
  2. The integer status value.

The following three functions can be used to decode the process status code returned by waitpid.

status:exit-val status Scheme Procedure
scm_status_exit_val (status) C Function
Return the exit status value, as would be set if a process ended normally through a call to exit or _exit, if any, otherwise #f.

status:term-sig status Scheme Procedure
scm_status_term_sig (status) C Function
Return the signal number which terminated the process, if any, otherwise #f.

status:stop-sig status Scheme Procedure
scm_status_stop_sig (status) C Function
Return the signal number which stopped the process, if any, otherwise #f.

system [cmd] Scheme Procedure
scm_system (cmd) C Function
Execute cmd using the operating system's "command processor". Under Unix this is usually the default shell sh. The value returned is cmd's exit status as returned by waitpid, which can be interpreted using the functions above.

If system is called without arguments, return a boolean indicating whether the command processor is available.

primitive-exit [status] Scheme Procedure
scm_primitive_exit (status) C Function
Terminate the current process without unwinding the Scheme stack. This is would typically be useful after a fork. The exit status is status if supplied, otherwise zero.

execl filename . args Scheme Procedure
scm_execl (filename, args) C Function
Executes the file named by path as a new process image. The remaining arguments are supplied to the process; from a C program they are accessible as the argv argument to main. Conventionally the first arg is the same as path. All arguments must be strings.

If arg is missing, path is executed with a null argument list, which may have system-dependent side-effects.

This procedure is currently implemented using the execv system call, but we call it execl because of its Scheme calling interface.

execlp filename . args Scheme Procedure
scm_execlp (filename, args) C Function
Similar to execl, however if filename does not contain a slash then the file to execute will be located by searching the directories listed in the PATH environment variable.

This procedure is currently implemented using the execvp system call, but we call it execlp because of its Scheme calling interface.

execle filename env . args Scheme Procedure
scm_execle (filename, env, args) C Function
Similar to execl, but the environment of the new process is specified by env, which must be a list of strings as returned by the environ procedure.

This procedure is currently implemented using the execve system call, but we call it execle because of its Scheme calling interface.

primitive-fork Scheme Procedure
scm_fork () C Function
Creates a new "child" process by duplicating the current "parent" process. In the child the return value is 0. In the parent the return value is the integer process ID of the child.

This procedure has been renamed from fork to avoid a naming conflict with the scsh fork.

nice incr Scheme Procedure
scm_nice (incr) C Function
Increment the priority of the current process by incr. A higher priority value means that the process runs less often. The return value is unspecified.

setpriority which who prio Scheme Procedure
scm_setpriority (which, who, prio) C Function
Set the scheduling priority of the process, process group or user, as indicated by which and who. which is one of the variables PRIO_PROCESS, PRIO_PGRP or PRIO_USER, and who is interpreted relative to which (a process identifier for PRIO_PROCESS, process group identifier for PRIO_PGRP, and a user identifier for PRIO_USER. A zero value of who denotes the current process, process group, or user. prio is a value in the range -20 and 20, the default priority is 0; lower priorities cause more favorable scheduling. Sets the priority of all of the specified processes. Only the super-user may lower priorities. The return value is not specified.

getpriority which who Scheme Procedure
scm_getpriority (which, who) C Function
Return the scheduling priority of the process, process group or user, as indicated by which and who. which is one of the variables PRIO_PROCESS, PRIO_PGRP or PRIO_USER, and who is interpreted relative to which (a process identifier for PRIO_PROCESS, process group identifier for PRIO_PGRP, and a user identifier for PRIO_USER. A zero value of who denotes the current process, process group, or user. Return the highest priority (lowest numerical value) of any of the specified processes.