Win32 programming advice needed for OSProcess port

Mark A. Schwenk mas at wellthot.com
Wed Feb 20 18:51:17 UTC 2002


At 10:52 AM 2/20/2002 -0500, David T. Lewis wrote:
>I am in the process of attempting a Win32 implementation of OSProcess.
>As a Windows newbie (I just bought a couple of books and downloaded the
>development tools from Andreas' site, but I have no experience yet),
>I could use some advice on the following:
>
>OSProcess can start external processes, and needs to receive notification
>when one of these processes exits. On Unix, I set a signal handler in the
>UnixOSProcessPlugin which handles the SIGCHLD ("death of child") signal
>from the operating system, and signals a Semaphore in Squeak to indicate
>that one of the child processes has exited. This mechanism works fine.
>
>On Windows, there are no "child processes" and no SIGCHLD available
>from the operating system. I think that the nearest equivalent mechanism
>is to start a Win32 thread which calls WaitForSingleObject() or
>WaitForMultipleObjects() to wait for the completion of one or more
>external processes. When the call to WaitForSingleObject() returns,
>the Squeak Semaphore would be signaled, and cleanup would proceed
>similarly to the Unix version.

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 
MsgWaitForMultipleObjects
to wait for a process termination or a message with another process handle 
to wait on 
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/prothred_633n.asp).

Since you are new to Windows programming, you may not be aware of the 
online references at http://msdn.microsoft.com. Processes and Threads 
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/prothred_86sz.asp) 
Synchronization 
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/synchro_4q3y.asp), 
and Messages and Message Queues 
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/messques_87mt.asp) 
might be two good topics to begin with.

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?

>I can see some potential here for missed signals and general thread
>nastiness, so I figure that this is a good time to ask: Am I using the
>"right" approach here?  Are there any horrible pitfalls I should know
>about (arbitrary limits on number of threads or handles, etc)? Is this
>a problem which has been solved before?
>
>Thanks in advance for any advice or pointers.
>
>Dave

OSProcess is great! Thanks for continuing your work. Good luck!

-Mark Schwenk
  WellThot Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20020220/98063f72/attachment.htm


More information about the Squeak-dev mailing list