<div dir="ltr">BTW, I'm writing this up into a larger message that explains the big picture and how everything ties together, I play to post that in a separate thread.  Maybe today, if I finish it, otherwise tomorrow.</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 22, 2014 at 11:30 AM, Zachary Turner <span dir="ltr"><<a href="mailto:zturner@google.com" target="_blank">zturner@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">The only way to wait for a process to exit is calling WaitForSingleObject() with the handle. You can specify a timeout to that function, and INFINITE is one possible value.  However, it seems like the primary use case for LLDB waiting for a process to exit is to fire off the exit callback asynchronously.  In that case Windows, like other platforms, will probably need to create a background thread, then WaitForSingleObject() on the background thread, then fire the callback after it returns.<div><br></div><div>What I was thinking is have the HostProcess provide a method called BlockUntilExit() which can be used anywhere (even from the main thread) should the caller desire it, but when launching a process we would create a thread for on each platform that just calls this method on the HostProcess, then issues the callback.  This would unify alot of code currently spread across the different Host.[cpp/mm] files.</div><div><br></div><div>One thing that still eludes me though, is that when processes are launched using Applescript, no monitoring thread is created, and it looks at least like the callback is never invoked on these processes.  Is this by design, a bug, or am I misreading the code?</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 22, 2014 at 11:15 AM, Greg Clayton <span dir="ltr"><<a href="mailto:gclayton@apple.com" target="_blank">gclayton@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">So you can get the exit status of a process using<br>
<br>
BOOL WINAPI GetExitCodeProcess(_In_ HANDLE hProcess, _Out_  LPDWORD lpExitCode);<br>
<br>
Is there a way to wait for the process to exit without polling? Or do you have to keep calling GetExitCodeProcess() until STILL_ACTIVE is not returned? I am guessing you can wait on the hProcess handle somehow?<br>
<br>
Anyway, it seems like we want the following when launching processes:<br>
<br>
1 - a way to wait for a process to finish with an optional timeout (which defaults to infinite)<br>
2 - a way to say, no need to wait for the process to finish<br>
<br>
For 1, we do what we are currently doing. The process monitor callback for windows will need to wait for the process to exit, then call GetExitCodeProcess() when done and return the value. On unix machines, we will reap the process and return the exit status.<br>
<br>
For 2, windows doesn't need to do anything, but we still need to reap the process on unix to avoid zombies.<br>
<br>
Not sure if I missed any scenarios?<br>
<span><font color="#888888"><br>
Greg<br>
</font></span><div><div><br>
<br>
> On Sep 22, 2014, at 9:33 AM, Zachary Turner <<a href="mailto:zturner@google.com" target="_blank">zturner@google.com</a>> wrote:<br>
><br>
> Yes, but closing the handle is semantically a different operation than reaping a process.  You can close a handle to a process while the process is still running and it doesn't affect anything except that it frees up space in your process's handle table.  You can also not close a handle, and if the process exits nothing bad will come of it.  So closing the handle is more tied to the lifetime of the instantiated HostProcess , and independent of the actual process running on ths system.<br>
><br>
> On Sun, Sep 21, 2014 at 11:40 PM, Matthew Gardiner <<a href="mailto:mg11@csr.com" target="_blank">mg11@csr.com</a>> wrote:<br>
> On Wed, 2014-09-17 at 00:27 -0700, Zachary Turner wrote:<br>
><br>
> > I know Join isn't really the right word, but there's no concept of<br>
> > reaping a process on Windows.<br>
><br>
> However, on Windows, isn't there still a requirement to CloseHandle that<br>
> handles returned by CreateProcess?<br>
><br>
> Matt<br>
><br>
><br>
><br>
><br>
><br>
> Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom<br>
> More information can be found at <a href="http://www.csr.com" target="_blank">www.csr.com</a>. Keep up to date with CSR on our technical blog, <a href="http://www.csr.com/blog" target="_blank">www.csr.com/blog</a>, CSR people blog, <a href="http://www.csr.com/people" target="_blank">www.csr.com/people</a>, YouTube, <a href="http://www.youtube.com/user/CSRplc" target="_blank">www.youtube.com/user/CSRplc</a>, Facebook, <a href="http://www.facebook.com/pages/CSR/191038434253534" target="_blank">www.facebook.com/pages/CSR/191038434253534</a>, or follow us on Twitter at <a href="http://www.twitter.com/CSR_plc" target="_blank">www.twitter.com/CSR_plc</a>.<br>
> New for 2014, you can now access the wide range of products powered by aptX at <a href="http://www.aptx.com" target="_blank">www.aptx.com</a>.<br>
><br>
</div></div><div><div>> _______________________________________________<br>
> lldb-dev mailing list<br>
> <a href="mailto:lldb-dev@cs.uiuc.edu" target="_blank">lldb-dev@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev</a><br>
<br>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>