Re: [PATCH v2] Implement close-on-fork

Matthew Wilcox
2020-05-15T16:26:31Z

On Fri, May 15, 2020 at 04:07:33PM +0000, Karstens, Nate wrote:
> Matthew,
>
> What alternative would you suggest?
>
> >From an earlier email:
>
> > ...nothing else addresses the underlying issue: there is no way to
> > prevent a fork() from duplicating the resource. The close-on-exec
> > flag partially-addresses this by allowing the parent process to
> > mark a file descriptor as exclusive to itself, but there is still
> > a period of time the failure can occur because the auto-close only
> > occurs during the exec(). Perhaps this would not be an issue with
> > a different process/threading model, but that is another discussion
> > entirely.
>
> Do you disagree there is an issue?

Yes. system() is defined as being unsafe for a threaded application
to call. I pointed this out in the last thread.