Linux 单分支守护进程。如何重新获取控制终端?
每个人都说守护程序不应该有控制终端。 双叉方法是双架守护程序永远不会获得控制终端的正确方法,因为它不是会话负责人。
但是,如果我们使用使用setSID()创建一个单叉守护程序,将所有FDS关闭,将FD 0〜2重定向到 /dev /null,但仍然是会话领导者。
那么它如何重新召集控制终端?为了看到它,我该怎么办? 我只想测试它真正获得控制终端。
当我使用ioctl和tiocsctty时,它永远不会成功,因为没有任何有效的FD作为参数。
Everyone says that daemon should not have a controlling terminal.
And double-fork method is the correct way that a double-forked daemon will never acquire a controlling terminal since it's not a session leader.
However, if we create a single fork daemon with using setsid(), close all fds, redirect fd 0~2 to /dev/null, but still the daemon is a session leader.
Then how can it reacquire a controlling terminal? What can i do in order to see it?
I just want to test it really acquires a controlling terminal or not.
When i used ioctl and TIOCSCTTY, it never succeeds since there is no any valid fd to pass as a parameter.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论