当调用 forkpty 时,X 会抛出错误。 (C++)
当我的程序到达此行时:
pid_t nPid = forkpty( &m_nMasterFD, NULL, NULL, NULL );
输出此:
X Error: BadIDChoice (invalid resource ID chosen for this connection) 14
Extension: 148 (RENDER)
Minor opcode: 17 (RenderCreateGlyphSet)
Resource id: 0x3600002
<unknown>: Fatal IO error 4 (Interrupted system call) on X server :0.0.
并终止。正如你所看到的,我正在尝试创建一个 pty 来运行东西,但它不起作用。
另外,有没有办法在类中调用 forkpty()
? (我尝试了两种方法,但都不起作用。)
我正在 Ubuntu 9.10 上使用 QT C++ 进行编程。
编辑:这是问题的链接最终对我有用的代码。
When my program gets to this line:
pid_t nPid = forkpty( &m_nMasterFD, NULL, NULL, NULL );
Outputs this:
X Error: BadIDChoice (invalid resource ID chosen for this connection) 14
Extension: 148 (RENDER)
Minor opcode: 17 (RenderCreateGlyphSet)
Resource id: 0x3600002
<unknown>: Fatal IO error 4 (Interrupted system call) on X server :0.0.
And terminates. As you can see, I'm trying to make a pty to run stuff in, but it's not working.
Also, is there a way forkpty()
can be called within a class? ( I tried both ways, but neither worked. )
I'm programming in QT C++ on Ubuntu 9.10.
EDIT: Here's a link to the question with the code that finally worked for me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
forkpty() 分叉您的进程。您需要首先关闭文件描述符,特别是子进程中与 X 服务器的连接。这意味着您可能无法使用 forkpty ,但必须在子进程中使用 openpty()、fork()、close 文件描述符、logintty/()
forkpty() forks your process. You need to close the filedescriptors first, in particular the connection to the X server in your child process. This means you likely cannot use forkpty , but have to use openpty(), fork(),close filedescriptors in the child process, logintty/()