Difference between using fork/execvp and system call

前端 未结 5 1117
小鲜肉
小鲜肉 2021-02-07 12:13

What is the difference between using system() to execute a binary and using the combination of fork/execvp.

Is there any security/portablility/performance difference.

5条回答
  •  清歌不尽
    2021-02-07 12:44

    Yes, system() runs the command through a shell, while exec() runs the command directly. Of course, introducing a shell opens up for bugs and exploits.

    Edit: of course, the man page provides more detail.

提交回复
热议问题