Oberon || Library || Module Index || Search Engine || Definition || Module


Ulm's Oberon Library:
SysProcess


NAME

SysProcess - UNIX process management

SYNOPSIS

TYPE Event = POINTER TO EventRec;
TYPE EventRec =
   RECORD
      (Events.EventRec)
      exitcode: INTEGER;
   END;


TYPE ProcessId = INTEGER; TYPE ProcessGroup = INTEGER; TYPE UserId = INTEGER; TYPE GroupId = INTEGER; TYPE Signal = SysSignals.Signal; TYPE Status = RECORD signal: Signal; exitcode: SHORTINT; core: BOOLEAN; stopped: BOOLEAN; END; (* Wait4 options; see <sys/wait.h> *) CONST nohang = 1; (* don't hang in wait *) CONST untraced = 2; (* tell about stopped, untraced children *)

PROCEDURE Getpid() : ProcessId; PROCEDURE Getpgrp() : ProcessGroup; PROCEDURE Getppid() : ProcessId; PROCEDURE Getuid() : UserId; PROCEDURE Geteuid() : UserId; PROCEDURE Getgid() : GroupId; PROCEDURE Getegid() : GroupId; PROCEDURE Kill(pid: INTEGER; sig: Signal; errors: RelatedEvents.Object) : BOOLEAN; PROCEDURE Exit(code: INTEGER); PROCEDURE Abort; PROCEDURE Fork(VAR pid: ProcessId; errors: RelatedEvents.Object) : BOOLEAN; PROCEDURE ExecEnv(path: ARRAY OF CHAR; argv, envp: SysArgs.Arguments; errors: RelatedEvents.Object); PROCEDURE Exec(path: ARRAY OF CHAR; argv: SysArgs.Arguments; errors: RelatedEvents.Object); PROCEDURE Wait(VAR status: Status; VAR pid: ProcessId; errors: RelatedEvents.Object) : BOOLEAN; PROCEDURE WaitFor(VAR pid: ProcessId; VAR status: Status; errors: RelatedEvents.Object) : BOOLEAN; PROCEDURE NonBlockingWait(VAR status: Status; VAR pid: ProcessId; errors: RelatedEvents.Object) : BOOLEAN; PROCEDURE NonBlockingWaitFor(VAR pid: ProcessId; VAR status: Status; errors: RelatedEvents.Object) : BOOLEAN; PROCEDURE Wait4(VAR pid: ProcessId; VAR status: Status; options: INTEGER; errors: RelatedEvents.Object; retry: BOOLEAN; VAR interrupted: BOOLEAN) : BOOLEAN; PROCEDURE Pause;

DESCRIPTION

SysProcess interfaces those UNIX system calls which are related to process management.

Exit causes immediate termination without raising events. Abort enforces a default reaction for SysSignals.ABRT and sends SysSignals.ABRT to the process which causes process termination (with core dump, if possible).

Getpid returns the process id, Getppid the process id of the parent process. Getpgrp returns the process group.

Getuid returns the real user id, Geteuid the effective user id of the calling process. Getgid returns the real group id, Getegid the effective group id of the calling process.

Kill sends sig to the process designated by pid. See kill(2) for details.

Fork creates a new process. pid is set to zero for the child process and to the process id of the child for the parent process. ExecEnv replaces the process image by path and passes argv and envp as command line parameters resp. environment parameters. path must be 0X-terminated. See UnixArgList for creation of argument lists. Exec is like ExecEnv but defaults envp to SysArgs.environ.

Wait waits for any child to be terminated. pid contains the process id of the terminated process and status the termination signal or the exit code. Fields of status:

____________________________________________________________________
|signal	    termination	causing	signal;	equals 0 if  terminated	 by|
|	    exit						   |
|exitcode   exit code (if signal = 0)				   |
|core	    core file produced?					   |
|stopped____stop_of_traced_process?________________________________|

Wait returns FALSE if there are no children to wait for.

WaitFor waits for the given children to terminate. The behaviour of WaitFor is modified if pid is less than 1:

____________________________________________________________________
|pid = 0    wait for any child process whose process  group  ID	 is|
|	    equal to that of the calling process.		   |
|pid = -1   wait for any child process;	the behaviour is equivalent|
|	    to Wait.						   |
|pid < 0    wait for any child process whose process  group  ID	 is|
|___________equal_to_the_absolute_value_of_pid.____________________|

NonBlockingWait and NonBlockingWaitFor are nonblocking variants of Wait and WaitFor They return FALSE and appropriate error events if no child has exited yet. Wait4 offers the most general interface to the corresponding system call. Valid options are nohang (nonblocking variant) and untraced (not only exited but also stopped children). Both options may be combined by giving nohang+untraced.

Pause suspends execution until receipt of a signal (see SysSignals) which is not ignored by the calling process. Pause does not raise an event of SysErrors in case of return.

DIAGNOSTICS

Failed system calls lead to events of SysErrors. The errors parameter is passed to SysErrors.Raise. All procedures return FALSE in case of errors.

SEE ALSO

exec(2)
Exec and ExecEnv
exit(2)
Exit
fork(2)
Fork
getpid(2)
Getpid and Getppid
getpgrp(2)
Getpgrp
getuid(2)
Getuid, Geteuid, Getgid, and Getegid
kill(2)
Kill
pause(2)
Pause
ptrace(2)
trace of processes
wait(2)
Wait and Status
Process
more portable interface for exiting and aborting
SysErrors
error handling

Edited by: borchert, last change: 1996/09/13, revision: 1.4.2.9, converted to HTML: 1997/04/28

Oberon || Library || Module Index || Search Engine || Definition || Module