Processes

STK provides access to Unix processes as first class objects. Basically, a process contains four informations: the standard Unix process identification (aka PIDndexfile(index-entry "PID" "rm" main )) and the three standard files of the process.





`=̀13`(ndexfile(index-entry "run-process" "tt" main )run-processcommand p1 p2 p3 … )
procedure
ndexfile(index-entry "run-process" "tt" aux )run-process creates a new process and run the executable specified in command. The p correspond to the command line arguments. The following values of p have a special meaning:

The following example launches a process which execute the Unix command ls with the arguments -l and /bin. The lines printed by this command are stored in the file /tmp/X $\Longrightarrow$
$\Longrightarrow$ unspecified error makeotherˆ`=̀13`

          gobblecr(run-process "ls" "-l" "/bin" :output "/tmp/X" :wait #f)





`=̀13`(ndexfile(index-entry "process?" "tt" main )process?process)
procedure
Returns #t if process is a process, otherwise returns #f.





`=̀13`(ndexfile(index-entry "process-alive?" "tt" main )process-alive?process)
procedure
Returns #t if process if the process is currently running, otherwise returns #f.





`=̀13`(ndexfile(index-entry "process-pid" "tt" main )process-pidprocess)
procedure
Returns an integer value which represents the Unix identification (PIDndexfile(index-entry "PID" "rm" main )) of process.





`=̀13`(ndexfile(index-entry "process-input" "tt" main )process-inputprocess)
procedure
`=̀13`(ndexfile(index-entry "process-output" "tt" main )process-outputprocess)
procedure
`=̀13`(ndexfile(index-entry "process-error" "tt" main )process-errorprocess)
procedure
Returns the file port associated to the standard input, output or error of process, if it is redirected in (or to) a pipe; otherwise returns #f. Note that the returned port is opened for reading when calling process-output or process-error; it is opened for writing when calling process-input.





`=̀13`(ndexfile(index-entry "process-wait" "tt" main )process-waitprocess)
procedure
ndexfile(index-entry "Process-wait" "tt" aux )Process-wait stops the current process until process completion. ndexfile(index-entry "Process-wait" "tt" aux )Process-wait returns #f when process is already terminated; it returns #t otherwise.





`=̀13`(ndexfile(index-entry "process-exit-status" "tt" main )process-exit-statusprocess)
procedure
ndexfile(index-entry "Process-exit-status" "tt" aux )Process-exit-status returns the exit status of process if it has finished its execution; returns #f otherwise.





`=̀13`(ndexfile(index-entry "process-send-signal" "tt" main )process-send-signalprocess n)
procedure
Send the signal whose integer value is n to process. Value of n is system dependant. Use the defined signal constants to make your program indpendant of the running system (see [*]). The result of process-send-signal is undefined.





`=̀13`(ndexfile(index-entry "process-kill" "tt" main )process-killprocess)
procedure
ndexfile(index-entry "Process-kill" "tt" aux )Process-kill brutally kills process. The result of ndexfile(index-entry "process-kill" "tt" aux )process-kill is undefined. This procedure is equivalent to $\Longrightarrow$
$\Longrightarrow$ unspecified error makeotherˆ`=̀13`


          gobblecr(process-send-signal process |SIGTERM|)





`=̀13`(ndexfile(index-entry "process-stop" "tt" main )process-stopprocess)
procedure
`=̀13`(ndexfile(index-entry "process-continue" "tt" main )process-continueprocess)
procedure
Those procedures are only available on systems which support job control. Process-stop stops the execution of process and process-continue resumes its execution. They are equivalent to $\Longrightarrow$
$\Longrightarrow$ unspecified error makeotherˆ`=̀13`


          gobblecr(process-send-signal process |SIGSTOP|)(process-send-signal process |SIGCONT|)





`=̀13`(ndexfile(index-entry "process-list" "tt" main )process-list)
procedure
ndexfile(index-entry "process-list" "tt" aux )process-list returns the list of processes which are currently running (i.e. alive).