From owner-freebsd-arch@FreeBSD.ORG Thu Nov 10 23:06:19 2011 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 292891065674 for ; Thu, 10 Nov 2011 23:06:19 +0000 (UTC) (envelope-from giovanni.trematerra@gmail.com) Received: from mail-vx0-f182.google.com (mail-vx0-f182.google.com [209.85.220.182]) by mx1.freebsd.org (Postfix) with ESMTP id D67E48FC08 for ; Thu, 10 Nov 2011 23:06:18 +0000 (UTC) Received: by vcbfo14 with SMTP id fo14so4248008vcb.13 for ; Thu, 10 Nov 2011 15:06:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=g5yZuKUXuEmgljaKKFHA7c5kVB4S5WjEPeK+LlFAtnE=; b=PcVXf61qgqC1MnkG5NJRS11niZPlrteKYaWDmfVWXB/EfzMJeR44szNp6C0o0SzcHg q6fb4lJNet/7E8TceTxj4AJlvvDEtVkEInxJe0Q2/y9v3cOwAGecIFVf9oQTW4w9IDGT wXerN+R3rJ1smjBkA1YC/xx2Kzjws9TLbIWD0= MIME-Version: 1.0 Received: by 10.229.29.73 with SMTP id p9mr1460149qcc.217.1320966378098; Thu, 10 Nov 2011 15:06:18 -0800 (PST) Sender: giovanni.trematerra@gmail.com Received: by 10.229.1.216 with HTTP; Thu, 10 Nov 2011 15:06:18 -0800 (PST) In-Reply-To: References: Date: Fri, 11 Nov 2011 00:06:18 +0100 X-Google-Sender-Auth: gwNoM1OPRvJYbooSZy7wEI3u5Xw Message-ID: From: Giovanni Trematerra To: Peter Wemm Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: Garrett Cooper , freebsd-arch@freebsd.org Subject: Re: deprecated TIOCSPGRP and TIOCGPGRP ioctl command X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Nov 2011 23:06:19 -0000 On Thu, Nov 10, 2011 at 8:18 PM, Peter Wemm wrote: > On Wed, Nov 9, 2011 at 5:52 PM, Garrett Cooper wrote= : >> On Nov 9, 2011, at 4:49 PM, Peter Wemm wrote: >> >>> On Wed, Nov 9, 2011 at 3:39 PM, Giovanni Trematerra wrote: >>>> Are they deprecated enough to be removed, now? >>>> FYI FIFO doesn't support them. >>>> >>>> -- >>>> Gianni >>>> >>>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >>>> --- sys/kern/sys_pipe.c (revision 227233) >>>> +++ sys/kern/sys_pipe.c (working copy) >>>> @@ -1304,17 +1304,6 @@ pipe_ioctl(fp, cmd, data, active_cred, td) >>>> =A0 =A0 =A0 =A0*(int *)data =3D fgetown(&mpipe->pipe_sigio); >>>> =A0 =A0 =A0 =A0break; >>>> >>>> - =A0 /* This is deprecated, FIOSETOWN should be used instead. */ >>>> - =A0 case TIOCSPGRP: >>>> - =A0 =A0 =A0 PIPE_UNLOCK(mpipe); >>>> - =A0 =A0 =A0 error =3D fsetown(-(*(int *)data), &mpipe->pipe_sigio); >>>> - =A0 =A0 =A0 goto out_unlocked; >>>> - >>>> - =A0 /* This is deprecated, FIOGETOWN should be used instead. */ >>>> - =A0 case TIOCGPGRP: >>>> - =A0 =A0 =A0 *(int *)data =3D -fgetown(&mpipe->pipe_sigio); >>>> - =A0 =A0 =A0 break; >>>> - >>>> =A0 =A0default: >>>> =A0 =A0 =A0 =A0error =3D ENOTTY; >>> >>> Be very very careful with this. =A0It's part of the classic BSD job >>> control API. =A0It would be wise to survey whether any ports shells use >>> this. >>> >>> You might also want to consider things like this in libc: >>> int >>> tcsetpgrp(int fd, pid_t pgrp) >>> { >>> =A0 =A0 =A0 =A0int s; >>> >>> =A0 =A0 =A0 =A0s =3D pgrp; >>> =A0 =A0 =A0 =A0return (_ioctl(fd, TIOCSPGRP, &s)); >>> } >>> Our own libc code uses this, albeit on an API intended to be used on a = tty. >>> >>> The shell I'd be most concerned about is csh/tcsh in our tree. It has >>> quite an #ifdef legacy layer and I couldn't convince myself it wasn't >>> using this indirectly (or the tc* functions) on pipes. >>> >>> It might also be an idea to see if the linux compat layer can be >>> switched over to using the newer API. >> >> Move to a compat library perhaps? >> -Garrett > > It's not a compat library candidate. > > Summary of the issue: > ioctl(fd, TIOCSPGRP, arg) can be used on sockets, pipes, ttys. =A0But not= fifos. > this is a classic BSD job control API. > libc itself uses this internally on ttys. > libc doesn't check that the function that does this is actually a tty, > it could be being used by shells and pipes as an obscure side effect. > The API is equivalent to FIOSETOWN etc and sockets and pipes use > common code to implement both ioctl() calls. > > The proposed patch was to remove the TIOCSPGRP -> FIOSETOWN mapping > for pipes only, to sync them with fifos. =A0ttys and sockets would be > unaffected. > > The implementation function still has to stay. =A0Its not a large chunk > of obsolete code that goes away, its just the mapping between the > ioctl number and the implementation. > Thank you Peter, just last question on this. Having just one ioctl function for both pipe and fifo, would be a problem having TIOCSPGRP and TIOCGPGRP implemented for fifo? -- Gianni