From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 50417 invoked by alias); 28 Aug 2017 11:39:21 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 49967 invoked by uid 89); 28 Aug 2017 11:39:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS,URIBL_RED autolearn=ham version=3.3.2 spammy= X-HELO: relay1.mentorg.com Date: Mon, 28 Aug 2017 11:39:00 -0000 From: Joseph Myers To: Florian Weimer CC: Christian Brauner , , , Subject: Re: [PATCH 2/2] openpty: use TIOCGPTPEER to open slave side fd In-Reply-To: <3496d984-a55e-d56b-2c25-a23200327dca@redhat.com> Message-ID: References: <20170826134449.26527-1-christian.brauner@ubuntu.com> <20170826134449.26527-2-christian.brauner@ubuntu.com> <3496d984-a55e-d56b-2c25-a23200327dca@redhat.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-SW-Source: 2017-08/txt/msg01186.txt.bz2 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