Previous: , Up: Processes   [Contents][Index]

5.27.8 Executing Shell Commands

Convenient shell invocatino is possible, with its I/O going to the same places as the interpreter’s.

Function: system command

Execute the shell command command synchronously, returning its exit status. An error will be signalled if the shell process could not be started.

The stdin, stdout and stderr streams of the shell are left as in the interpreter process.

The subprocesses environment is copied from the current value of the process-environment variable.

Note that the exit status is not the same as the return code of the command. It depends on the operating system, but under UNIX the return code can be found through right-shifting the exit status by eight bits. Low non-zero values represent that the process was killed by a signal.

It is possible to interrupt a running shell process in the same way as with a normal synchronous process (see Synchronous Processes). Interrupt the interpreter, it will send progressively harder-to-ignore signals to the child each interrupt, until it is eventually terminated.