C - Get PID of process opened with popen

后端 未结 2 1731
滥情空心
滥情空心 2021-01-20 01:56

I have a program written in C, which opens another program using popen. I \'d like to get the pid of that program or some kind of handler for it, so as to kill it after a ce

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-20 02:41

    Just write your own implementation of popen that returns the PID. It's much less ugly than some crazy hackery around the existing popen. You can find source code to popen implementations all over the net. Here's one.

提交回复
热议问题