File:  [WindowsNT SDKs] / q_a / samples / termq / readme
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Thu Aug 9 18:29:19 2018 UTC (7 years, 9 months ago) by root
Branches: msft, MAIN
CVS tags: ntsdk-jun-1992, HEAD
Microsoft Windows NT Build 297 06-28-1992

 Sample: Porting a DosStartSession Termination Queue

Summary:

This sample code demonstrates how to start multiple
processes and wait on them to terminate. It also
demonstrates how to convert the OS/2 method of reading from
a "termination queue" to the equivalent Win32 API function
calls.

In the sample, a number of child processes are started. The
program then waits for any of them to end via the Win32
WaitForMultipleObjects function call. As soon as a process
terminates, the return code for the terminated process is
retrieved and reported to the console.

More Information:

After starting child sessions with DosStartSession in OS/2,
if you want to be notified when the child sessions
terminate, you must create a queue and pass the handle to
that queue into the DosStartSession call. When a child
session ends, you receive a queue packet containing
information about which session (by session ID) ended and
what the termination code of that session is.

A major limitation of this method is that you are allowed
only one termination queue per parent; this imposes some
complications with multiple-threaded applications starting
multiple sessions in different threads; you cannot have
multiple threads reading from the same termination queue at
the same time. The common solution is to have one central
termination queue thread that reads from the termination
queue (all of the child sessions's termination packets
arrive in this one Queue), and process all of the
termination queue packets for all of the other threads.

Under Win32, this complication is not there. Each thread
that starts a new session simply waits for the new process
handle to be signaled.

This demonstration does not involve multiple threads, nor
does it demonstrate the complexity of the OS/2 version of
multiple threads waiting for multiple sessions to terminate.
It demonstrates the more simple case of starting a few
sessions and waiting for all of them to end; the Win32
technique used is still fully demonstrated without including
a great deal of OS/2 code.

The following is a list of the Win32 API functions used in
this sample:

   CloseHandle   CreateProces  GetLastErro  WaitForMultipleOb
                 s             r            jects



unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.