[comp.os.os2.programmer] spawning

rommel@lan.informatik.tu-muenchen.dbp.de (Kai-Uwe Rommel) (08/17/90)

Some days ago I ported the MS-SH 1.6.2, a Bourne shell implementation for
DOS, to OS/2. Of course I implemented now background processes. The SH uses
spawnve(), now with P_NOWAIT mode and before printing the next prompt, I
use DosCwait() with no-wait mode to look for ending child processes to clean
up the process slot and report it's return code.

This works all fine in a full screen session. Thats also it's main purpose
for me, to be run in a full screen session and to provide background processes
in the same session. This does not allow to start PM programs from within the
shell because this would require DosStartSession() instead of DosExecPgm()
which is used by spawn().

I noticed some strange things now. One can use the CMD.EXE whith the command
"CMD /C START <pm-app> ..." to spawn a PM program from this shell.
But this seems to cause trouble to PM because some time later (not
immediately) the PM hangs and requires a Ctrl-Alt-Delete. This occures most
often, when the PS program (from the 1.1 Toolkit) is used after spawning
a PM app. this way. Does anyone have an idea about the reasons?

Also, I noticed, when the shell is run in a PM VIO window, it has problems
with background processes. When I, for example, start a MAKE or something
like that (my CS compiler driver) as a background process with &, and this
itself now spawns the C compiler (in P_WAIT mode), then the C compiler never
ends. Something goes wrong with its DosExit() call. In runs normally to its
end, but then stops and never returns to MAKE. This process is then listed
as a zombie in the process table. But when I then start any other command from
the shell (even a simple synchronous LS), then the C compiler exits and the
driver starts the Linker, which then also stops before exiting and only
returns to the caller, when another command is started. When the compilation
ends, the DosCwait() does not always get the return code from the MAKE at the
first attempt.

That all looks rather strange, because it only occures when the shell is run
in a PM VIO window. What does the PMSHELL do differrent with the child
processes in the PM session than in the fullscreen sessions?

And with a spawn(P_NOWAIT, ...) one cannot make much wrong ...
I'm really fascinated that the main problems occur, when the process
spawned with P_NOWAIT itself spawns with simple P_WAIT mode. Any ideas?

Thanks,
Kai Uwe Rommel
--
/* Kai Uwe Rommel
 * Munich
 * rommel@lan.informatik.tu-muenchen.dbp.de
 */