HP 3000 Manuals

system [ MPE/iX Developer's Kit Reference Manual Volume I ] MPE/iX 5.0 Documentation


MPE/iX Developer's Kit Reference Manual Volume I

system 

Execute a command using the shell. 

Syntax 

     #include <stdlib.h>
     int system(const char *command);

Parameters 

command          is a string giving the command line for the command you
                 want to execute using the shell (MPE/iX Shell).

Return Values 

If command is NULL, system() returns -1.

If command is not NULL, system() returns the exit status of the sh
command that executes command.  If sh cannot be invoked to execute the
command, the return value of system() is the value that would be received
if sh terminated with exit(127).

If system() cannot fork() a child process, it returns -1 and sets errno
to an appropriate value.  It uses the same errno values used by fork()
for its possible failures.

Description 

system() executes the command specified by command.  It does this as if
it spawns a child process with fork(), then the child process invokes the
shell sh with

      execl(shellpath, "sh", "-c", command, NULL);

where shellpath is the pathname of the file that contains the MPE/iX
Shell.

system() ignores the SIGINT and SIGQUIT signals while waiting for the
command to terminate.  It also blocks the SIGCHLD signal.  After the
command terminates, the calling process can examine the return value from
system() to determine if any of these signals should be handled.

Implementation Considerations 

None.

Errors 

None.

See Also 

sh(1)



MPE/iX 5.0 Documentation