Process started from system command in C inherits parent fd's

后端 未结 5 907
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-09 19:36

I have a sample application of a SIP server listening on both tcp and udp ports 5060. At some point in the code, I do a system(\"pppd file /etc/ppp/myoptions &\");

5条回答
  •  南方客
    南方客 (楼主)
    2020-12-09 20:23

    system() copies current process and then launch a child on top of it. (current process is no more there. that is probably why pppd uses 5060. You can try fork()/exec() to create a child process and keep parent alive.

提交回复
热议问题