How does system () work exactly in Linux?

I've read his man page but haven't yet had time to figure out how it works. When system () is called, is the new child process forked and the exec () - ed shell binary in it? However, this can be silly.

+8


a source to share


2 answers


Yes, system () is essentially fork () and exec () "sh -c" for the passed command line. An example implementation (from eglibc, recently forked from glibc) can be found here .



+11


a source


Yes, system ("foo bar") is equivalent to execv ("/ bin / sh", ["sh", "-c", "foo bar"]).



+2


a source







All Articles