<html>
At 10:52 AM 2/20/2002 -0500, David T. Lewis wrote:<br>
<blockquote type=cite class=cite cite>I am in the process of attempting a
Win32 implementation of OSProcess.<br>
As a Windows newbie (I just bought a couple of books and downloaded
the<br>
development tools from Andreas' site, but I have no experience 
yet),<br>
I could use some advice on the following:<br><br>
OSProcess can start external processes, and needs to receive
notification<br>
when one of these processes exits. On Unix, I set a signal handler in
the<br>
UnixOSProcessPlugin which handles the SIGCHLD (&quot;death of
child&quot;) signal<br>
from the operating system, and signals a Semaphore in Squeak to
indicate<br>
that one of the child processes has exited. This mechanism works
fine.<br><br>
On Windows, there are no &quot;child processes&quot; and no SIGCHLD
available<br>
from the operating system. I think that the nearest equivalent
mechanism<br>
is to start a Win32 thread which calls WaitForSingleObject() or<br>
WaitForMultipleObjects() to wait for the completion of one or more<br>
external processes. When the call to WaitForSingleObject() returns,<br>
the Squeak Semaphore would be signaled, and cleanup would proceed<br>
similarly to the Unix version.</blockquote><br>
I'd go for a single process that creates a message-only window to serve
as its message queue (see
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/messques_8ht1.asp),
gets messages containing more process handles to wait on from other
processes doing a SendMessage to its window message queue, and then uses
<font color="#0000FF"><b><u>MsgWaitForMultipleObjects <br>
</u></b></font>to wait for a process termination or a message with
another process handle to wait on
(<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/prothred_633n.asp" eudora="autourl">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/prothred_633n.asp</a>).<br><br>
Since you are new to Windows programming, you may not be aware of the
online references at
<a href="http://msdn.microsoft.com/" eudora="autourl">http://msdn.microsoft.com</a>.
Processes and Threads
(<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/prothred_86sz.asp" eudora="autourl">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/prothred_86sz.asp</a>)
Synchronization
(<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/synchro_4q3y.asp" eudora="autourl">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/synchro_4q3y.asp</a>),
and Messages and Message Queues
(<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/messques_87mt.asp" eudora="autourl">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/messques_87mt.asp</a>)
might be two good topics to begin with.<br><br>
I think the above should work, but it's been a while since I've done much
Win32 programming. Can anyone else comment on this approach?<br><br>
<blockquote type=cite class=cite cite>I can see some potential here for
missed signals and general thread<br>
nastiness, so I figure that this is a good time to ask: Am I using
the<br>
&quot;right&quot; approach here?&nbsp; Are there any horrible pitfalls I
should know<br>
about (arbitrary limits on number of threads or handles, etc)? Is
this<br>
a problem which has been solved before?<br><br>
Thanks in advance for any advice or pointers.<br><br>
Dave</blockquote><br>
OSProcess is great! Thanks for continuing your work. Good luck!<br>
<x-sigsep><p></x-sigsep>
-Mark Schwenk<br>
&nbsp;WellThot Inc.</html>