如何检测预分叉服务器中所有子级都阻止接受()的父级死亡
假设我有一个预分叉服务器。启动时,服务器侦听套接字并分叉多个子级。然后,所有子级都会阻塞其 accept()
系统调用,直到客户端发送请求,其中一个子级将处理该请求。通过使用 SIGCHLD 处理程序,父级可以轻松检测到其子级的死亡。但孩子们如何得知父母去世的消息呢?所有子级都阻塞在他们的accept()调用上,因此他们无法轮询父级是否存在。
Suppose I have a pre-fork server. On start up, the server listens on a socket and forks multiple children. All children then block on their accept()
system call until a client sends a request, upon which one of the children will handle the request. It is easy for the parent to detect the death of its children by using a SIGCHLD handler. But how can the children be informed about the death of their parent? All the children are blocking on their accept()
call, so they would not be able to poll for the presence/absence of the parent.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论