Difference between “system” and “exec” in Linux?

前端 未结 12 1932
天命终不由人
天命终不由人 2020-11-28 05:18

What is the difference between system and exec family commands? Especially I want to know which one of them creates child process to work?

12条回答
  •  忘掉有多难
    2020-11-28 05:48

    exec() replaces the current running process with the process image of the function being performed..only executable files can be invoked using this.

    system() forks off a new process implicitly to service the request and returns the value it obtained through the child process it forked initially.It uses the system's default shell to carry out the operation.

提交回复
热议问题