我需要用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
}
如果您需要任何其他信息,请询问。谢谢。
编辑:我没有子代码的访问权限。我只是想运行可执行文件。