What happens to parent process, when a child process is created using vfork() and killed before calling exec

Dave Mitchell davem at iabyn.com
Wed Oct 29 16:16:28 UTC 2014


On Tue, Oct 28, 2014 at 11:01:31AM +0000, Kevin Peterson wrote:
> Hi, 
> 
> When a process is created using vfork() child process is created and
> starts running in the parent process address space, until exit() or
> exec() is called. 
> 
> What happens to the parent process, if some one kills the child process
> before calling the exit()/exec()?

According to the vfork man page:

       vfork()  differs  from  fork(2) in that the calling thread is suspended
       until the child terminates (either normally, by  calling  _exit(2),  or
       abnormally,  after  delivery  of a fatal signal), or it makes a call to
       execve(2).  Until that point, the child shares all memory with its par‐
       ent,  including  the stack.  The child must not return from the current
       function or call exit(3), but may call _exit(2).

So I should imagine that when the child is killed, the parent resumes,
and can call wait() and retrieve the child's exit status.


-- 
"Procrastination grows to fill the available time"
    -- Mitchell's corollary to Parkinson's Law


More information about the users mailing list