NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/49017: vfork does not suspend all threads



The following reply was made to PR kern/49017; it has been noted by GNATS.

From: Nico Williams <Nico.Williams%twosigma.com@localhost>
To: <gnats-bugs%netbsd.org@localhost>
Cc: 
Subject: Re: kern/49017: vfork does not suspend all threads
Date: Thu, 6 Apr 2017 16:57:14 +0000

 Robert Elz <kre%munnari.OZ.AU@localhost> wrote:
 > [ description of vfork_into_fork() elided ]
 
 That's a neat idea, but I don't think it's needed.  I can't think of why I
 would ever need it or any time that I could have used it.
 
 What I really want is
 
     pid_t avfork(int (*)(void *), void *);
 
 which is like vfork() but allocates a new stack, calls the given callback in it
 just like pthread_create() would, and does not stop any threads in the parent,
 not even the one that called it.  The 'a' stands for "asynchronous".
 
 Note that avfork() would have much the same constraints for the child as
 vfork() does, except, naturally, that the avfork() child could return while the
 vfork() child cannot.
 
 I have written portable multi-processed daemons that build on Unix and Windows.
 What I do on Windows is I spawn() the child processes, exec'ing the same
 executable as the parent and passing in information needed by the child via
 arguments or a pipe.  On Unix I get lazy and fork(), but what I do on Windows
 would work just as well on Unix.  You can see this here:
 
 https://github.com/heimdal/heimdal/blob/master/lib/roken/detach.c
 
 Nico
 -- 
 



Home | Main Index | Thread Index | Old Index