Hi Eric,

> openpty is worthless in a multithreaded app like libvirt - there's no 
> way to make the master and slave fds atomically O_CLOEXEC

As a workaround, you can posix_spawn() a subprocess that will do the
openpty() call, and then copy the file descriptors to the parent process
using the 'passfd' module. On Linux, MSG_CMSG_CLOEXEC exists, therefore
recvfd() will set the O_CLOEXEC flag atomically.

> I know that glibc does not (yet) provide a flags variant of openpty, 
> although I created a request:
> 
> http://sourceware.org/bugzilla/show_bug.cgi?id=13385

It makes sense.

> Should we go ahead and implement a safer openpty() in gnulib, while 
> waiting for the glibc decision on that bug?

I'd say, wait a bit for Ulrich's answer.

On the gnulib side, we would also have to implement openpty2 on the
platforms that already have openpty. These are: glibc, MacOS X, FreeBSD,
OSF/1, Cygwin.

Bruno
-- 
In memoriam Bernhard Lichtenberg 
<http://en.wikipedia.org/wiki/Bernhard_Lichtenberg>

Reply via email to