Guardian Native C Library Calls Reference Manual (G06.28+, H06.05+)
Guardian Native C Library Calls (s) system(3)
NAME
system - Executes an OSS shell command or TACL command
LIBRARY
G-series native Guardian processes: $SYSTEM.SYSnn.ZCRTLSRL
G-series native OSS processes: /G/system/sysnn/zcrtlsrl
H-series native Guardian processes: $SYSTEM.ZDLLnnn.ZCRTLDLL
H-series OSS processes: /G/system/zdllnnn/zcrtldll
SYNOPSIS
#include <stdlib.h>
int system(
const char ∗∗command);
PARAMETERS
command Specifies a valid sh OSS shell or TACL command.
DESCRIPTION
In OSS processes, the system() function passes the command parameter to the sh command,
which interprets command as a command and executes it.
In Guardian processes, the system() function passes the command parameter to a TACL com-
mand process, which inteprets command as a command and executes it.
The function can be called only from a Guardian module (a module compiled for the Guardian
environment) within a Guardian process or from an OSS module (a module compiled for the OSS
environment) within an OSS process. The function cannot be called by both Guardian and OSS
modules within the same process. The compiled-module and process environments must be the
same.
Separate OSS and Guardian environment descriptions follow.
Use From OSS Processes
The system( ) function invokes the fork() function to create a child process that in turn uses a
member of the exec family of functions to run sh, which interprets the shell command contained
in the command parameter. The current process waits until the shell has finished, then returns the
exit status of the shell. Note that the system() function affects only the processes that it created.
While waiting for command to finish executing, the system() function blocks the SIGCHLD,
SIGINT, and SIGQUIT signals. If this characteristic causes your application to miss a signal
that might have terminated the application, you should have the application check the system()
function’s return value and then perform the operation that would have been executed if the
application had caught that signal.
Use From Guardian Processes
The first time the system() function is invoked, a TACL process is started with a null OUT file
and the current default volume and subvolume names. The current default names are used by the
C run-time code to expand all partial filenames. This default can be changed with the chvol()
function.
The TACL process continues to service calls to the system() function. Thus, by making succes-
sive calls to the system() function, you establish a context for the TACL command process.
RETURN VALUES
The following return values apply to the system() function called from OSS processes:
• The system() function does not return until its child process has terminated.
• If the command parameter is a null pointer, the system() function returns a value of 1
only if a command processor is available.
527192-007 Hewlett-Packard Company 6−105