tags:

views:

103

answers:

1

Hello, all.

When my program gets to this line,:

pid_t nPid = forkpty( &m_nMasterFD, NULL, NULL, NULL );

it 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. :P

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. Help appereciated, thanks in advance!

EDIT: Here's a link to the question with the code that finally worked for me.

+2  A: 

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/()

nos
Isn't this what `O_CLOEXEC` is for?
ephemient
If you exec() a new program, yes. In this case there's just fork().
nos
Oh. Somehow I thought that `forkpty()` had a final `exec` in there, but no, of course it doesn't...
ephemient