Date: Fri, 11 Nov 2011 00:06:18 +0100 From: Giovanni Trematerra <gianni@freebsd.org> To: Peter Wemm <peter@wemm.org> Cc: Garrett Cooper <yanegomi@gmail.com>, freebsd-arch@freebsd.org Subject: Re: deprecated TIOCSPGRP and TIOCGPGRP ioctl command Message-ID: <CACfq093r9%2BFjAM5cOTJy=_f8_73qw-0x5GrSt3VYRg=B03UfsA@mail.gmail.com> In-Reply-To: <CAGE5yCqSfJuemRgT7agTsydbBAJSrnAbyyoP3h%2BJ-JJMd1OAMw@mail.gmail.com> References: <CACfq09210zdar=%2BM40gLoVtZnwLda88T1FJBbLXiy9e3t8-9NQ@mail.gmail.com> <CAGE5yCor9c%2Bb7hZaF8NLdxc2F8PPfi0kTZFLXY5nvA%2Bbm1Ytuw@mail.gmail.com> <D2F25708-5E0B-4270-83F0-79286C5A581A@gmail.com> <CAGE5yCqSfJuemRgT7agTsydbBAJSrnAbyyoP3h%2BJ-JJMd1OAMw@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Nov 10, 2011 at 8:18 PM, Peter Wemm <peter@wemm.org> wrote: > On Wed, Nov 9, 2011 at 5:52 PM, Garrett Cooper <yanegomi@gmail.com> wrote= : >> On Nov 9, 2011, at 4:49 PM, Peter Wemm wrote: >> >>> On Wed, Nov 9, 2011 at 3:39 PM, Giovanni Trematerra <gianni@freebsd.org= > 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CACfq093r9%2BFjAM5cOTJy=_f8_73qw-0x5GrSt3VYRg=B03UfsA>