Difference between using fork/execvp and system call

前端 未结 5 1235
小鲜肉
小鲜肉 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:32

    system() will fork()/exec() the shell, and then shell will fork()/exec() the program you want to launch.

    So system() is twice as heavy as fork()/exec()

提交回复
热议问题