We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
//waitpid(pid, &status, 0);我觉得应该放在这里啊 while (read(cgi_output[0], &c, 1) > 0) send(client, &c, 1, 0); close(cgi_output[0]); close(cgi_input[1]); /*此处存在疑问,不应该将waitpid放在前面吗?以确保子进程先运行*/ waitpid(pid, &status, 0);
waitpid放在最后如何保证子进程结束后可以send给client?
The text was updated successfully, but these errors were encountered:
waitpid 是为了回收子进程使用的资源,为了防止出现僵尸进程吧,等子进程结束之后才会调用它吧, while (read(cgi_output[0], &c, 1) > 0) 主进程还在与子进程交互。
while (read(cgi_output[0], &c, 1) > 0)
Sorry, something went wrong.
read带有阻塞,所以read(cgi_output[0])本来就是等待子进程(cgi)已经确定了子进程先执行,至于waitpid就是简单回收子进程防止僵尸进程
No branches or pull requests
waitpid放在最后如何保证子进程结束后可以send给client?
The text was updated successfully, but these errors were encountered: