Syntax
#include <qshell.h> int QzshSystem( const char *command );
|
The QzshSystem() function runs the specified shell command by spawning a child process and invoking qsh in the child process. qsh interprets and runs command and then exits.
The QzshSystem() function returns when the child process has ended. While the QzshSystem() function is waiting for the child process to end, it ignores the SIGQUIT and SIGINT signals, and blocks the SIGCHLD signal. The QzshSystem() function does not affect the status information of any other child processes started by the calling process.
Parameters
*command
(Input) Pointer to null-terminated string that contains the shell
command to run.
Authorities
Object Referred To | Authority Required | errno |
---|---|---|
Each directory in the path name preceding the executable file | *X | EACCES |
Executable file | *X | EACCES |
If executable file is a shell script | *RX | EACCES |
Return value
Error conditions
If QzshSystem() is not successful, errno typically indicates one of the following errors. Under some conditions, errno could indicate an error other than those listed here.
Related information
Example: Using the QzshSystem() and QzshCheckShellCommand() functions
The following example shows how to use the QzshSystem() and QzshCheckShellCommand() functions.
#include <stdio.h> #include <qshell.h> #include <sys/wait.h> #include <errno.h> int main(int argc, char *argv[]) { int status; char *command = "ls"; /* Verify the user has access to the specified command. */ if (QzshCheckShellCommand(command, NULL) == 0) { /* Run the specified command. */ status = QzshSystem(command); if (WIFEXITED(status)) { printf("Command %s completed with exit status %d.\n", command, WEXITSTATUS(status)); } else if (WIFSIGNALED(status)) { printf("Command %s ended with signal %d.\n", command, WTERMSIG(status)); } else if (WIFEXCEPTION(status)) { printf("Command %s ended with exception.\n", command); } } else printf("Error %d finding command %s\n", errno, command); return(0); }Output
Command ls completed with exit status 0.