我必须用 C 编写一个程序来fork
创建一个新进程,然后将该进程pid
用于另一个函数。但是我需要在子进程运行之前调用这个函数,我不知道该怎么做。
这是我正在尝试做的一些伪代码。
pid_t pid = fork();
if(in_child){ //In the child process
//launch child application
//somehow stop the child application before it actually executes any code
}
else{
//call my function with the child's pid
//resume the child process
//do other stuff
}
如果您需要任何其他信息,请询问。谢谢。
编辑:我无权访问孩子的代码。我只是想运行一个可执行文件。