Microsoft KB Archive/58779

From BetaArchive Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

BUG: After Increasing Available File Handles, exec() Hangs

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: - The C Run-time (CRT), included with: - 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 ---------------------------------------------------------------------- SYMPTOMS ======== 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. CAUSE ===== There is a known incompatibility between changing the startup source code for the C run-time library and exec'ing multiple child processes. STATUS ====== 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. MORE INFORMATION ================ 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. Sample Code ----------- /* Compile options needed: none */ #define FILES_OPEN 30 #include #include #include #include #include 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 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
Issue type :
Technology : kbVCsearch kbAudDeveloper kbCRT


Last Reviewed: May 5, 2001
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.