How does system() exactly work in linux?

前端 未结 2 389
礼貌的吻别
礼貌的吻别 2020-12-16 23:29

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()

相关标签:
2条回答
  • 2020-12-17 00:06

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

    0 讨论(0)
  • 2020-12-17 00:18

    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.

    0 讨论(0)
提交回复
热议问题