[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: openpty needs a variant with a flags argument
From: |
Bruno Haible |
Subject: |
Re: openpty needs a variant with a flags argument |
Date: |
Sat, 5 Nov 2011 09:39:45 +0100 |
User-agent: |
KMail/1.13.6 (Linux/2.6.37.6-0.5-desktop; KDE/4.6.0; x86_64; ; ) |
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>