CHAINing (as Opposed to EXECing) Processes

ID Number: Q32733

2.x 3.00 3.10 3.20 3.21 3.30 3.30a

MS-DOS

Question:

Is there a way to "chain" processes under MS-DOS? I wish to start a

process from the MS-DOS command prompt, then have this first process

start a second process and pass control to it, similar to using EXEC

(interrupt 21h service 4Bh). However, unlike using EXEC, this CHAIN

would free all memory associated with the first process. When the

second process terminates, it would return to the MS-DOS command

prompt, and not return control to the first process. Is this possible?

If not, is there any way to simulate this ability using existing

MS-DOS system services?

Response:

There no way to do what you wish directly, using the system

services built into MS-DOS. The most reasonable way to simulate this

is to have the first process do a SETBLOCK (interrupt 21h service 4Ah)

before calling the second, shrinking itself down to a stub that calls

EXEC for the second process. The first process would wait for return

of control from the second process and then terminate. Done

efficiently, this would take about 20h bytes of code plus the PSP, for

a total of about 12h paragraphs.