This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 2/2] openpty: use TIOCGPTPEER to open slave side fd
On Mon, 28 Aug 2017, Florian Weimer wrote:
> On 08/26/2017 03:44 PM, Christian Brauner wrote:
> > +#ifdef TIOCGPTPEER
> > + slave = ioctl (master, TIOCGPTPEER, O_RDWR | O_NOCTTY);
> > +#else
> > if (pts_name (master, &buf, sizeof (_buf)))
> > goto fail;
> >
> > slave = open (buf, O_RDWR | O_NOCTTY);
> > +#endif
>
> I don't think you can #ifdef out existing code this way without
> introducing failures on older kernels. You need to try the ioctl first,
> and if that fails, use the old pts_name code.
And in principle there should be appropriate __ASSUME_* conditionals so
that when building with a new-enough --enable-kernel the old code can be
conditioned out (however, because this code is not Linux-specific, the old
case would need to stay in the code even when __ASSUME_TIOCGPTPEER is
defined unconditionally in the Linux kernel-features.h).
--
Joseph S. Myers
joseph@codesourcery.com