[PATCH] tfork
Andrew Bartlett
abartlet at samba.org
Wed Apr 19 10:29:08 UTC 2017
On Tue, 2017-04-18 at 16:22 -0700, Jeremy Allison via samba-technical
wrote:
> On Tue, Apr 18, 2017 at 09:55:56PM +0200, Ralph Böhme via samba-
> technical wrote:
> > Hi!
> >
> > Attached is a patchset that adds a signal and waitpid() avoiding
> > fork()
> > replacement: tfork().
> >
> > It was based on an older patchset from metze, called double_fork at
> > that time,
> > that I extended to fork three-times in order to return a pollable
> > status fd.
> >
> > It's intented use is in samba_runcmd_send() where it avoids calling
> > waitpid()
> > and dealing with SIGCHLD to get the exit status of the executed
> > command.
> >
> > With this change it is safe to call samba_runcmd_send() in smbd
> > code as an async
> > replacement for smbrun().
> >
> > I have a usecase here where someone wants to run shell scripts from
> > source3
> > code without blocking.
> >
> > Please review & push if happy.
>
> I'm looking at this right now, but it's making my brain hurt :-).
>
> I've gotten as far as realizing the use of _exit() gets you out
> of all sorts of reinit_after_fork() problems and atexit()
> issues.
>
> Still reviewing....
>
> Jeremy.
Having been bitten by the SIGCHLD causing the loss of error codes
(until I reworked the standard process model code to use pipes to
detect which child dies), I'm very glad to see some innovation here.
Andrew Bartlett
--
Andrew Bartlett http://samba.org/~abartlet/
Authentication Developer, Samba Team http://samba.org
Samba Developer, Catalyst IT http://catalyst.net.nz/services/samba
More information about the samba-technical
mailing list