[Haskell-cafe] Discussion: The CLOEXEC problem

Donn Cave donn at avvanta.com
Sun Aug 30 14:59:27 UTC 2015

Quoth Niklas Hambüchen <mail at nh2.me>,
> On 25/07/15 21:09, Donn Cave wrote:
>> But there are other things that could turn up.
>> For example, you could use flock(2) (Berkeley, not POSIX fcntl
>> lock) to keep an advisory file lock until the exec exits.  If the
>> file is closed prematurely, you lose the lock, and ... whatever
>> happens then.

> This is a very valid point. Applications that rely on this will break by
> changing the default here.

... and you go on to demonstrate that you didn't really take the point
I was trying to make.  How did you find out about this flock(2) scenario?
Do you suppose that this is the only one, because you and I don't know
of any more?

My point is not that the whole thing might hinge on whether we can
deal with flock locking in this scenario, it is that when we think
about reversing ancient defaults in the underlying system, we have
to assume the risk of obscure breakage as a result.  To worry about
the flock problem now is to miss the point.

And again, this half-a-fix inconsistently applies to only files created
by open(2), and not to pipes, sockets and whatever else creates a file
descriptor in some other way, so if it's a real problem, it seems you
must address it in some other way anyway.


More information about the Haskell-Cafe mailing list