1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
4 /*============================================================
6 ** Source: CreateProcessA/test1/childprocess.c
8 ** Purpose: Test to ensure CreateProcessA starts a new process. This test
9 ** launches a child process, and examines a file written by the child.
10 ** This code is the child code.
12 ** Dependencies: GetCurrentDirectory
20 **=========================================================*/
24 const char *szCommonFileA = "childdata.tmp";
26 const char *szPathDelimA = "\\";
28 const char *szCommonStringA = "058d2d057111a313aa82401c2e856002\0";
31 * Take two wide strings representing file and directory names
32 * (dirName, fileName), join the strings with the appropriate path
33 * delimiter and populate a wide character buffer (absPathName) with
34 * the resulting string.
36 * Returns: The number of wide characters in the resulting string.
37 * 0 is returned on Error.
47 extern const char *szPathDelimA;
49 DWORD sizeDN, sizeFN, sizeAPN;
51 sizeDN = strlen( dirName );
52 sizeFN = strlen( fileName );
53 sizeAPN = (sizeDN + 1 + sizeFN + 1);
55 /* insure ((dirName + DELIM + fileName + \0) =< _MAX_PATH ) */
56 if ( sizeAPN > _MAX_PATH )
61 strncpy(absPathName, dirName, dwDirLength +1);
62 strncpy(absPathName, szPathDelimA, 2);
63 strncpy(absPathName, fileName, dwFileLength +1);
69 int __cdecl main( int argc, char **argv )
78 char szDirNameA[_MAX_DIR];
79 char szAbsPathNameA[_MAX_PATH];
81 if(0 != (PAL_Initialize(argc, argv)))
86 dwDirLength = GetCurrentDirectory( _MAX_PATH, szDirNameA );
90 Fail ("GetCurrentDirectory call failed. Could not get "
91 "current working directory\n. Exiting.\n");
94 dwFileLength = strlen( szCommonFileA );
96 dwSize = mkAbsoluteFilenameA( szDirNameA, dwDirLength, szCommonFileA,
97 dwFileLength, szAbsPathNameA );
101 Fail ("Palsuite Code: mkAbsoluteFilename() call failed. Could "
102 "not build absolute path name to file\n. Exiting.\n");
105 if ( NULL == ( fp = fopen ( szAbsPathNameA , "w+" ) ) )
108 * A return value of NULL indicates an error condition or an
111 Fail ("%s unable to open %s for writing. Exiting.\n", argv[0]
115 if ( 0 >= ( fprintf ( fp, "%s", szCommonStringA )))
117 Fail("%s unable to write to %s. Exiting.\n", argv[0]
121 if (0 != (fclose ( fp )))
123 Fail ("%s unable to close file %s. Pid may not be "
124 "written to file. Exiting.\n", argv[0], szAbsPathNameA );