ssystem -- secure variant of system()
int ssystem(char** argv)
ssystem forks off a new process which execs to the path
found in argv[0]
and passes argv as command line arguments
to it. The parent process waits until the spawned off process
exits.
SIGINT and SIGQUIT are ignored by the parent process during the lifetime of the subprocess. fflush is invoked to flush all output streams.
In comparison with system, ssystem avoids the involvement of a shell process which includes the possible interpretation of meta characters. This is dangerous if the list of arguments comes from untested user input.
In case of errors, -1 is returned. Otherwise, the status of the terminated subprocess is returned.
As ssystem does not know about opened pipelines and other opened files, they are shared with the forked-off process.
Andreas Borchert