Microsoft KB Archive/23740

{|
 * width="100%"|

PRB: spawnl Fails in Noncurrent Directory
'Article ID: Q23740

Creation Date: 16-DEC-1987

Revision Date: 18-DEC-1995' 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 for OS/2, versions 5.1, 6.0, and 6.0a - Microsoft C/C++ for MS-DOS, version 7.0 - Microsoft Visual C++ for Windows, versions 1.0 and 1.5 - Microsoft Visual C++ 32-bit Edition, versions 1.0, 2.0, and 4.0 

SYMPTOMS

An attempt to use the spawnl function to invoke a child process fails if the child is in a directory other than the current directory. However, invoking a child process in the current directory succeeds.

CAUSE

The MS-DOS, OS/2, and Windows NT operating systems use the backslash character (\) to separate the directory name from the file name in a file specification. The C language also uses the backslash as an "escape" character to indicate a special character, such as the end-of-line character (\n). These uses conflict in an application.

RESOLUTION

Modify the file specification in the spawnl call to specify two backslashes between the portions of the file specification.

MORE INFORMATION

The following spawnl command does not work as expected:

spawnl(P_WAIT, "c:\dir1\file.exe", "file.exe", NULL); The following spawnl command works correctly: spawnl(P_WAIT, "c:\\dir1\\file.exe", "file.exe", NULL);
 * }

-

"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." '' ©1997 Microsoft Corporation. All rights reserved. Legal Notices.

''

Additional reference words: 1.00 1.50 2.00 5.10 6.00 6.00a 6.00ax 7.00 4.00

KBCategory: kbprg kbfasttip kbprb

KBSubcategory: CRTIss