Environment variables categories
Platform
Process handling
File system

Process handling [XL]


categories Process handlingnormal dispatch [XL] Core method

fork() -> integer

fork is the standard UNIX interface to create new processes. fork creates a child process that is an image of the current process that only differs by the returned value which is:

under win32 it produce a system error.


categories Process handlingnormal dispatch [XL] Kernel method

getpid() -> integer

getpid() returns the process id of the calling process


categories Process handlingnormal dispatch [XL] Kernel method

getppid() -> integer

getppid() returns the parent process id of the calling process


categories Process handlingnormal dispatch [XL] Kernel method

getuid() -> integer

getuid() returns the real user ID of the calling process. Under windows this method always returns 0


categories Process handlingnormal dispatch [XL] Kernel method

kill(p:integer) -> void

kill(p) terminates the process identified by the process id p. It first give a chance to the process to exit gracefully upon receipt of a SIGTERM signal. If the process still runs after a short timeout then a SIGKILL signal is send to the process. The caller should have necessary permissions.


categories Process handlingnormal dispatch [XL] Core interface

on_fork :: property(open = 3)

fork, when called in CLAIRE applies all existing on_fork with the domain void. the on_fork callback is applied just before the fork, that is the parent process only. For instance :
 on_fork() : void -> printf("attemp to fork...\n")


categories Process handlingnormal dispatch [XL] Core interface

on_forked :: property(open = 3)

after a fork, CLAIRE applies all existing on_forked restrictions that have the domain boolean. the on_forked callback is applied with true from the child and false from the parent process. For instance :
 on_forked(parent?:boolean: void ->
         printf("just forked (~I)\n",
                     (if parent? princ("parent")
                     else printf("child ~S"getpid())))


categories Process handlingopen [XL] Core class

process_status <: thing

Instances

WRUNNING, WEXITED, WSIGNALED, WSTOPPED

A process status is returned by waitpid and tell how a child process has exited:


categories Process handlingnormal dispatch [XL] Core method

waitpid(p:integer) -> tuple(process_status, integer, any)

waitpid(p) is equivalent to waitpid(p, true)


categories Process handlingnormal dispatch [XL] Core method

waitpid(p:integer, block?:boolean) -> tuple(process_status, integer, any)

waitpid is a the UNIX interface to get status of child process. The parameter p specifies the set of child processes to wait for:

block?, when true, tell that the call should block until a waited child terminates.