program not executing anything after a call to system()

后端 未结 2 1508
滥情空心
滥情空心 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: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.

提交回复
热议问题