ID: Q58779
5.10 6.00 6.00a 6.00ax 7.00 | 1.00 1.50
MS-DOS | WINDOWS
kbprg kbbuglist
The information in this article applies to:
- Microsoft C for MS-DOS, versions 5.1, 6.0, 6.0a, and 6.0ax
- Microsoft C/C++ for MS-DOS, version 7.0
- Microsoft Visual C++ for Windows, versions 1.0 and 1.5
In Microsoft C, modifying the C Run-time startup code to increase the maximum number of open file handles and streams can cause a program that does multiple exec's to hang.
There is a known incompatibility between changing the startup source code for the C run-time library and exec'ing multiple child processes.
Microsoft has confirmed this to be a problem in the products and versions listed above. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
The sample code below demonstrates this problem. If you make a copy of this program and call it CHILD.C, and change all references in the CHILD.C program from child to parent, you will have a loop of exec's set up. You can exec the child once, then your machine either hangs on the call to exec() the first program again or as the second program is finishing execution.
/* Compile options needed: none
*/
#define FILES_OPEN 30
#include <stdio.h>
#include <conio.h>
#include <process.h>
#include <errno.h>
#include <string.h>
void main ( void )
{
short numfiles, returnval;
FILE *FilePointer;
char fname[80];
for ( numfiles = 0; numfiles < FILES_OPEN; numfiles ++ )
{
sprintf ( fname, "file%2d.dat", numfiles ) ;
printf ( "Opening file #%2d :%s\n", numfiles, fname ) ;
if ( ( FilePointer = fopen ( fname, "a+" ) ) == NULL )
{
printf ( "fopen failed on file #%2d", numfiles ) ;
exit ( -2 ) ;
}
}
printf ( " Press <esc> to quit, other to exec child:\n" );
if ( ( returnval = getche() ) == 27 )
{
printf ( "Quitting...\n" ) ;
exit ( 1 ) ;
}
if(( returnval=execlp("child.exe", "child.exe", NULL)) == -1)
{
printf ( "Error exec'ing child; ERRNO: %d\n", errno ) ;
}
}
Additional reference words: 5.10 6.00 6.00a 6.00ax 7.00 1.00 1.50 P_OVERLAY SPAWN KBCategory: kbprg kbbuglist KBSubcategory: CRTIss Keywords : kb16bitonly
Last Reviewed: July 18, 1997