I've been reading its man page but haven't yet been successful in figuring out how it works. On calling system(), is a new child process forked and the shell binary exec()-ed in it? That may be a stupid guess though.
A:
Yes, system("foo bar") is equivalent to execv("/bin/sh", ["sh", "-c", "foo bar"]).
daf
2009-05-16 11:36:20
Posix requires that system() ignore SIGINT and SIGQUIT and block SIGCHLD.
Bastien Léonard
2009-05-16 11:39:44
Yes. The example implementation Lance pointed to does that.
2009-05-16 11:50:33
+4
A:
Yes, system() is essentially a fork() and exec() "sh -c" for the passed command string. An example implementation (from eglibc, recently forked from glibc) can be found here.
Lance Richardson
2009-05-16 11:40:53