Command should be a list with at least one element: The first list element (a path name in ECLiPSe path name syntax, atom or string) specifies the program to be executed, and the subsequent list elements are its arguments. The arguments can be atoms, strings or numbers. They are passed to the executed program literally (in particular, no path name syntax conversion is applied).
For backward compatibility, Command can be a simple atom or string, in which case the first word in Command specifies the program to be executed, and the following words are its command-line arguments. This form is deprecated since it creates problems with argument quoting and operating system dependent path name syntax.
By specifying the Streams argument it is possible to control which of the process' standard streams are connected to ECLiPSe streams. The form of Streams is [Stdin, Stdout, Stderr]. If some of these streams are specified and not null, a pipe is opened which connects the standard stream of the child process with the specified ECLiPSe stream, e.g. Stdin must be an output stream because it is connected to the standard input of the child process. If the list Streams is shorter, only the specified streams are connected with a pipe. The streams can be specified like for open/3. If the stream is a variable, it is bound to a stream handle, if it is an atom different from null, that symbolic stream name is used. Specifying a null stream means that no pipe is set up for this stream.
Each stream can also be specified as sigio(Stream) (UNIX systems only). In this case a pipe is set up to the stream Stream and in addition the pipe is instructed to send the signal io each time new data appears in it. In this way the two processes can communicate in a truly asynchronous way. When one process sends data to the other one, the interrupt handler is invoked and it can read and process the data. When it finishes, it can continue where it was interrupted.
After forking the process, Pid is unified with its process ID, which can be used e.g. in wait/2 or kill/2. If the exec system call in the child process failed, the child exits with status 128 + errno.
As oppsed to exec/3, the child process is created in a new process group (UNIX), and as a consequence does not get the interrupt, hangup and kill signals sent to the parent. This feature might be needed if e.g. a separate ECLiPSe process is forked which should not be influenced when the user types Ctrl-C to the main ECLiPSe process.
Success: % the child process does not get the signal if ^C is typed [eclipse]: exec_group(eclipse, [output], Pid). Pid = 11459 yes. [eclipse]: ECLiPSe Constraint Logic Programming System [kernel] Kernel and basic libraries copyright Cisco Technology Inc Academic licensing through Imperial College London, see legal/licence_acad.txt GMP library copyright Free Software Foundation, see legal/lgpl.txt For other libraries see their individual copyright notices Version 5.8 #72, Fri Nov 26 00:12 2004 [eclipse]: ^C interruption: type a, b, c, e, or h for help : ? % when exec/3 is used, both processes get the signal [eclipse]: exec(eclipse, [output], Pid). Pid = 11440 yes. [eclipse]: ECLiPSe Constraint Logic Programming System [kernel] Kernel and basic libraries copyright Cisco Technology Inc Academic licensing through Imperial College London, see legal/licence_acad.txt GMP library copyright Free Software Foundation, see legal/lgpl.txt For other libraries see their individual copyright notices Version 5.8 #72, Fri Nov 26 00:12 2004 [eclipse]: ^C interruption: type a, b, c, e, or h for help : ? interruption: type a, b, c, e, or h for help : ? Error: exec_group(S, [], Pid). (Error 4). exec_group(ls, null, Pid). (Error 5). exec_group(chipc, [1], P). (Error 5). exec_group(date, [input], P). (Error 192).