[lldb-dev] Process spawning and shutdown
Zachary Turner
zturner at google.com
Tue Sep 16 12:55:54 PDT 2014
Just a follow-up. It seems like there are three use cases for the
StartMonitoringChildProcess code-path (poorly named, since FreeBSD and
linux process plugins also have a ProcessMonitor class leading to great
confusion).
1) Some places want to Join() on a process exiting. They currently do this
by calling Join() on a HostThread returned by StartMonitoringChildProcess,
but the important thing is just that they want to join, not how it's
implemented.
2) Processes need to be reaped when they exit so as not to leave zombie
processes.
3) Some places want to have a user-specified callback executed
asynchronously in an arbitrary thread context when a process exits.
Does this cover everything? There's currently alot of built in assumptions
about which platforms want what subset of the above functionality, but I
think I'm starting to get a pretty good handle on this code and have a good
idea of how to restructure it to be more platform-agnostic. Want to make
sure I understand all the primary use cases first though.
On Tue, Sep 16, 2014 at 11:55 AM, Zachary Turner <zturner at google.com> wrote:
> The last major piece of the Host layer I'd like to address is process
> launching and cleanup. From looking over the code it seems we have the
> following different ways to launch a process:
>
> MacOSX:
> * Applescript
> * XPC
> * posix_spawn
>
> Other posix variants:
> * posix_spawn
>
> Windows:
> * Native windows launcher
>
>
> Among these, there are a couple of different ways to reap processes on
> exit and/or "join" on them. These are:
>
> MacOSX:
> * Applescript [ No process reaping or monitoring occurs. ]
> * XPC [ Uses MacOSX-specific dispatch library for
> monitoring ]
> * posix_spawn [ Uses MacOSX-specific dispatch library for monitoring ]
>
> Other posix variants:
> * posix_spawn [ Launches a background thread to monitor for process
> exit, join on the thread to join on the process ]
>
> Windows:
> * Native windows launcher [ WaitForSingleObject ]
>
> A few questions:
>
> 1) Is Join() on a process a useful operation that people would be
> interested in seeing implemented for all platforms?
>
> 2) On Linux at least, if you don't waitpid() on a process you'll end up
> with zombies. It seems this is true on MacOSX as well, because I see
> waitpid() in StartMonitoringChildProcess. Is this not true for the
> Applescript launcher? Why doesn't the Applescript launching code path call
> StartMonitoringChildProcess() anywhere?
>
> 3) Speaking of the Applescript launcher, what is it and what is it used
> for?
>
>
> I'll probably have more questions as I wrap my head around this a little
> more. Thanks
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20140916/f25eb260/attachment.html>
More information about the lldb-dev
mailing list