COHERENT manpages

This page displays the COHERENT manpage for system() [Pass a command to the shell for execution].

List of available manpages
Index


system() -- General Function (libc)

Pass a command to the shell for execution
#include <stdlib.h>
int system(commandline) char *commandline;

system() passes commandline to the shell sh, which loads it into memory and
executes it.  system() executes commands  exactly as if they had been typed
directly into  the shell.   system() may  be used by  commands such  as ed,
which can  pass commands  to the COHERENT  shell in addition  to processing
normal interactive requests.

Example

This example  uses system to  list the names  of all C source  files in the
parent directory.

#include <stdio.h>
#include <stdlib.h>

main()
{
    system("cd .. ; ls *.c > mytemp; cat mytemp");
}

See Also

exec
fork(),
libc,
popen(),
stdlib.h,
wait()
ANSI Standard, §7.10.4.5

Diagnostics

system()  returns the  exit  status of  the  child process,  in the  format
described in  wait(): exit status  in the high byte,  signal information in
the low byte.  Zero  normally means success, whereas nonzero normally means
failure.   This, however,  depends  on the  command.  If the  shell is  not
executable, system() returns a special code of octal 0177.