KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q43537: Critical Error during Spawn Will Lose Parent

Article: Q43537
Product(s): See article
Version(s): 5.10
Operating System(s): MS-DOS
Keyword(s): ENDUSER | s_quickc | mspl13_c
Last Modified: 17-MAY-1989

A critical error occurs when spawning another program using one of the
C Version 5.10 run-time library's spawn functions that can prevent the
child program from returning to the parent process. A sample program
is shown below.

This is not a problem with the run-time library, but is a limitation
of the spawn family of functions.

A workaround is to attempt to open the .EXE file before the spawn. The
critical error will occur on the open and allow DOS and the run-time
library to handle any problems encountered in a more elegant fashion.

The following program can be used to demonstrate the situation:

    #include <stdio.h>
    #include <process.h>

    void main( void )
    {
        spawnlp( P_WAIT, "a:\\test.exe", "a:\\test.exe", NULL );
    }

If Drive A is ready, TEST.EXE will be spawned correctly and return to
the parent. However, if the drive door is open, the following prompt
will be produced by the DOS critical error handler "Abort, Retry,
Fail?".

If the drive door is closed and "Retry" is selected, TEST.EXE will run
but not return to the parent, hanging the system. An assembly language
program that simply calls DOS interrupt 4B to do the same thing will
work correctly under the same conditions.

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.