program not executing anything after a call to system()

后端 未结 2 1425
滥情空心
滥情空心 2020-12-06 21:44

I am calling a command via system(command) call. But no other code is executed after this system() call.

Why is so? I thought, system() would create a child process

相关标签:
2条回答
  • 2020-12-06 22:26

    You have to fork(2) to continue executing code.

    0 讨论(0)
  • 2020-12-06 22:27

    The system(3) function causes your process to wait for the completion of the child.

    Edit 0:

    You have to use the classic pair of fork(2) and execve(2) for what you want to do. You might also check whether your C library provides POSIX spawn(3).

    Edit 1:

    Look into waitpid(2) to keep the parent around.

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