Re: I'm done with O_CLOEXEC

2015-03-20 Thread Jürg Billeter
On Fri, 2015-03-20 at 16:43 -0400, Ryan Lortie wrote: > What led me to this was the dup3() system call. This is a variant of > dup2() that was added (as part of the efforts mentioned above) to avoid > the O_CLOEXEC race: > > int dup3(int oldfd, int newfd, int flags); > > unfortunately: > >

Re: I'm done with O_CLOEXEC

2015-03-20 Thread Jürg Billeter
On Sat, 2015-03-21 at 01:32 -0400, Ryan Lortie wrote: > It seems that this is a (slightly) recent addition. It's documented: > >F_DUPFD_CLOEXEC (int; since Linux 2.6.24) > > so I'm sure we'll probably still need to write an ifdef with a > fallback... If you're referring to older Linux v

Re: I'm done with O_CLOEXEC

2015-03-20 Thread Ryan Lortie
hi, On Sat, Mar 21, 2015, at 01:27, Jürg Billeter wrote: > Doesn't the following standard POSIX functionality provide what you > want? > > fcntl(fd, F_DUPFD_CLOEXEC, 0) Yes. It does. Thank you very much. It seems that this is a (slightly) recent addition. It's documented: F_DUP

Re: I'm done with O_CLOEXEC

2015-03-20 Thread Ryan Lortie
hi, On Sat, Mar 21, 2015, at 01:19, Jasper St. Pierre wrote: > Right now, we use raw fork/exec in mutter where we need to do some tricky > management and explicitly leak an FD into the correct place [0]. Does > this > mean that from now on, glib might leak an FD and we need to be prepared > to > h

Re: I'm done with O_CLOEXEC

2015-03-20 Thread Ryan Lortie
On Fri, Mar 20, 2015, at 20:29, Christian Hergert wrote: > What I would welcome, is a function that says "glib, close all FDs you > know about or that you created". If all the libraries did that, at least > it would be possible for applications to maybe, sorta, do the right > thing. (That would

Re: I'm done with O_CLOEXEC

2015-03-20 Thread Jasper St. Pierre
Sorry, I'm not overly familiar with this sort of stuff. Right now, we use raw fork/exec in mutter where we need to do some tricky management and explicitly leak an FD into the correct place [0]. Does this mean that from now on, glib might leak an FD and we need to be prepared to handle that? Refac

Re: I'm done with O_CLOEXEC

2015-03-20 Thread Ryan Lortie
On Fri, Mar 20, 2015, at 23:33, Matthias Clasen wrote: > So, you found that dup3 doesn't do what you want, and now you want to > throw out the baby with the bathwater and just say "I don't care > anymore if we leak fds" ? dup3() was a bit of a "straw that broke the camel's back" case. I could po

Re: I'm done with O_CLOEXEC

2015-03-20 Thread Matthias Clasen
So, you found that dup3 doesn't do what you want, and now you want to throw out the baby with the bathwater and just say "I don't care anymore if we leak fds" ? On Fri, Mar 20, 2015 at 4:43 PM, Ryan Lortie wrote: > karaj, > > For those unfamiliar with the issue: when a process is created on UNIX

Re: I'm done with O_CLOEXEC

2015-03-20 Thread Paul Davis
On Fri, Mar 20, 2015 at 7:29 PM, Christian Hergert wrote: > > This makes me happy. I don't think I've actually seen any of this stuff > handled right. Not to mention that close() itself is basically broken in > multi-threaded scenarios on Linux (Linus says to basically "just not worry > about it

Re: I'm done with O_CLOEXEC

2015-03-20 Thread Christian Hergert
On 03/20/2015 01:43 PM, Ryan Lortie wrote: karaj, For those unfamiliar with the issue: when a process is created on UNIX via naive fork() and exec(), the default is that the process will inherit all of the file descriptors of the parent. This makes a lot of sense for stdin, stdout and stderr, b

I'm done with O_CLOEXEC

2015-03-20 Thread Ryan Lortie
karaj, For those unfamiliar with the issue: when a process is created on UNIX via naive fork() and exec(), the default is that the process will inherit all of the file descriptors of the parent. This makes a lot of sense for stdin, stdout and stderr, but almost nothing else. This has been the ca