1 /***
2 *process.h - definition and declarations for process control functions
3 *
4 *           Copyright (c) Microsoft Corporation. All rights reserved.
5 *
6 *Purpose:
7 *           This file defines the modeflag values for spawnxx calls.
8 *           Also contains the function argument declarations for all
9 *           process control related routines.
10 *
11 *           [Public]
12 *
13 ****/
14
15 #if        _MSC_VER > 1000
16 #pragma once
17 #endif
18
19 #ifndef _INC_PROCESS
20 #define _INC_PROCESS
21
22 #include <crtdefs.h>
23
24 #ifndef _POSIX_
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 /* modeflag values for _spawnxx routines */
31
32 #define _P_WAIT               0
33 #define _P_NOWAIT           1
34 #define _OLD_P_OVERLAY  2
35 #define _P_NOWAITO          3
36 #define _P_DETACH           4
37
38 #ifdef  _MT
39 #define _P_OVERLAY          2
40 #else
41 extern int _p_overlay;
42 #define _P_OVERLAY          _p_overlay
43 #endif  /* _MT */
44
45 /* Action codes for _cwait(). The action code argument to _cwait is ignored
46      on Win32 though it is accepted for compatibilty with old MS CRT libs */
47 #define _WAIT_CHILD          0
48 #define _WAIT_GRANDCHILD 1
49
50
51 /* function prototypes */
52
53 #ifdef  _MT
54 _CRTIMP uintptr_t __cdecl _beginthread (_In_ void (__cdecl * _StartAddress) (void *),
55              _In_ unsigned _StackSize, _In_opt_ void * _ArgList);
56 _CRTIMP void __cdecl _endthread(void);
57 _CRTIMP uintptr_t __cdecl _beginthreadex(_In_opt_ void * _Security, _In_ unsigned _StackSize,
58              _In_ unsigned (__stdcall * _StartAddress) (void *), _In_opt_ void * _ArgList, 
59              _In_ unsigned _InitFlag, _In_opt_ unsigned * _ThrdAddr);
60 _CRTIMP void __cdecl _endthreadex(_In_ unsigned _Retval);
61
62 #if defined(__cplusplus) && defined(_M_CEE)
63 extern "C++"
64 {
65 _MCRTIMP uintptr_t __cdecl _beginthread (_In_ void (__clrcall * _StartAddress) (void *),
66                _In_ unsigned _StackSize, _In_opt_ void * _ArgList);
67 _MCRTIMP uintptr_t __cdecl _beginthreadex(_In_opt_ void * _Security, _In_ unsigned _StackSize,
68              _In_ unsigned (__clrcall * _StartAddress) (void *), _In_opt_ void * _ArgList, 
69              _In_ unsigned _InitFlag, _Out_opt_ unsigned * _ThrdAddr);
70 }
71 #endif
72
73 #endif
74
75 #ifndef _CRT_TERMINATE_DEFINED
76 #define _CRT_TERMINATE_DEFINED
77 _CRTIMP __declspec(noreturn) void __cdecl exit(_In_ int _Code);
78 _CRTIMP __declspec(noreturn) void __cdecl _exit(_In_ int _Code);
79 _CRTIMP void __cdecl abort(void);
80 #endif
81
82 _CRTIMP void __cdecl _cexit(void);
83 _CRTIMP void __cdecl _c_exit(void);
84 _CRTIMP int __cdecl _getpid(void);
85
86 _CRTIMP intptr_t __cdecl _cwait(_Out_opt_ int * _TermStat, _In_ intptr_t _ProcHandle, _In_ int _Action);
87 _CRTIMP intptr_t __cdecl _execl(_In_z_ const char * _Filename, _In_z_ const char * _ArgList, ...);
88 _CRTIMP intptr_t __cdecl _execle(_In_z_ const char * _Filename, _In_z_ const char * _ArgList, ...);
89 _CRTIMP intptr_t __cdecl _execlp(_In_z_ const char * _Filename, _In_z_ const char * _ArgList, ...);
90 _CRTIMP intptr_t __cdecl _execlpe(_In_z_ const char * _Filename, _In_z_ const char * _ArgList, ...);
91 _CRTIMP intptr_t __cdecl _execv(_In_z_ const char * _Filename, _In_z_ const char * const * _ArgList);
92 _CRTIMP intptr_t __cdecl _execve(_In_z_ const char * _Filename, _In_z_ const char * const * _ArgList, _In_opt_z_ const char * const * _Env);
93 _CRTIMP intptr_t __cdecl _execvp(_In_z_ const char * _Filename, _In_z_ const char * const * _ArgList);
94 _CRTIMP intptr_t __cdecl _execvpe(_In_z_ const char * _Filename, _In_z_ const char * const * _ArgList, _In_opt_z_ const char * const * _Env);
95 _CRTIMP intptr_t __cdecl _spawnl(_In_ int _Mode, _In_z_ const char * _Filename, _In_z_ const char * _ArgList, ...);
96 _CRTIMP intptr_t __cdecl _spawnle(_In_ int _Mode, _In_z_ const char * _Filename, _In_z_ const char * _ArgList, ...);
97 _CRTIMP intptr_t __cdecl _spawnlp(_In_ int _Mode, _In_z_ const char * _Filename, _In_z_ const char * _ArgList, ...);
98 _CRTIMP intptr_t __cdecl _spawnlpe(_In_ int _Mode, _In_z_ const char * _Filename, _In_z_ const char * _ArgList, ...);
99 _CRTIMP intptr_t __cdecl _spawnv(_In_ int _Mode, _In_z_ const char * _Filename, _In_z_ const char * const * _ArgList);
100 _CRTIMP intptr_t __cdecl _spawnve(_In_ int _Mode, _In_z_ const char * _Filename, _In_z_ const char * const * _ArgList,
101              _In_opt_z_ const char * const * _Env);
102 _CRTIMP intptr_t __cdecl _spawnvp(_In_ int _Mode, _In_z_ const char * _Filename, _In_z_ const char * const * _ArgList);
103 _CRTIMP intptr_t __cdecl _spawnvpe(_In_ int _Mode, _In_z_ const char * _Filename, _In_z_ const char * const * _ArgList,
104              _In_opt_z_ const char * const * _Env);
105
106 #ifndef _CRT_SYSTEM_DEFINED
107 #define _CRT_SYSTEM_DEFINED
108 _CRTIMP int __cdecl system(_In_opt_z_ const char * _Command);
109 #endif
110
111 #ifndef _WPROCESS_DEFINED
112 /* wide function prototypes, also declared in wchar.h  */
113 _CRTIMP intptr_t __cdecl _wexecl(_In_z_ const wchar_t * _Filename, _In_z_ const wchar_t * _ArgList, ...);
114 _CRTIMP intptr_t __cdecl _wexecle(_In_z_ const wchar_t * _Filename, _In_z_ const wchar_t * _ArgList, ...);
115 _CRTIMP intptr_t __cdecl _wexeclp(_In_z_ const wchar_t * _Filename, _In_z_ const wchar_t * _ArgList, ...);
116 _CRTIMP intptr_t __cdecl _wexeclpe(_In_z_ const wchar_t * _Filename, _In_z_ const wchar_t * _ArgList, ...);
117 _CRTIMP intptr_t __cdecl _wexecv(_In_z_ const wchar_t * _Filename, _In_z_ const wchar_t * const * _ArgList);
118 _CRTIMP intptr_t __cdecl _wexecve(_In_z_ const wchar_t * _Filename, _In_z_ const wchar_t * const * _ArgList,
119              _In_opt_z_ const wchar_t * const * _Env);
120 _CRTIMP intptr_t __cdecl _wexecvp(_In_z_ const wchar_t * _Filename, _In_z_ const wchar_t * const * _ArgList);
121 _CRTIMP intptr_t __cdecl _wexecvpe(_In_z_ const wchar_t * _Filename, _In_z_ const wchar_t * const * _ArgList, 
122              _In_opt_z_ const wchar_t * const * _Env);
123 _CRTIMP intptr_t __cdecl _wspawnl(_In_ int _Mode, _In_z_ const wchar_t * _Filename, _In_z_ const wchar_t * _ArgList, ...);
124 _CRTIMP intptr_t __cdecl _wspawnle(_In_ int _Mode, _In_z_ const wchar_t * _Filename, _In_z_ const wchar_t * _ArgList, ...);
125 _CRTIMP intptr_t __cdecl _wspawnlp(_In_ int _Mode, _In_z_ const wchar_t * _Filename, _In_z_ const wchar_t * _ArgList, ...);
126 _CRTIMP intptr_t __cdecl _wspawnlpe(_In_ int _Mode, _In_z_ const wchar_t * _Filename, _In_z_ const wchar_t * _ArgList, ...);
127 _CRTIMP intptr_t __cdecl _wspawnv(_In_ int _Mode, _In_z_ const wchar_t * _Filename, _In_z_ const wchar_t * const * _ArgList);
128 _CRTIMP intptr_t __cdecl _wspawnve(_In_ int _Mode, _In_z_ const wchar_t * _Filename, _In_z_ const wchar_t * const * _ArgList,
129              _In_opt_z_ const wchar_t * const * _Env);
130 _CRTIMP intptr_t __cdecl _wspawnvp(_In_ int _Mode, _In_z_ const wchar_t * _Filename, _In_z_ const wchar_t * const * _ArgList);
131 _CRTIMP intptr_t __cdecl _wspawnvpe(_In_ int _Mode, _In_z_ const wchar_t * _Filename, _In_z_ const wchar_t * const * _ArgList,
132              _In_opt_z_ const wchar_t * const * _Env);
133 #ifndef _CRT_WSYSTEM_DEFINED
134 #define _CRT_WSYSTEM_DEFINED
135 _CRTIMP int __cdecl _wsystem(_In_opt_z_ const wchar_t * _Command);
136 #endif
137
138 #define _WPROCESS_DEFINED
139 #endif
140
141 /*
142  * Security check initialization and failure reporting used by /GS security
143  * checks.
144  */
145 #if !defined(_M_CEE)
146 void __cdecl __security_init_cookie(void);
147 #ifdef  _M_IX86
148 void __fastcall __security_check_cookie(_In_ uintptr_t _StackCookie);
149 __declspec(noreturn) void __cdecl __report_gsfailure(void);
150 #else
151 void __cdecl __security_check_cookie(_In_ uintptr_t _StackCookie);
152 __declspec(noreturn) void __cdecl __report_gsfailure(_In_ uintptr_t _StackCookie);
153 #endif
154 #endif
155 extern uintptr_t __security_cookie;
156
157 /* --------- The following functions are OBSOLETE --------- */
158 /*
159  * The Win32 API LoadLibrary, FreeLibrary and GetProcAddress should be used
160  * instead.
161  */
162
163 _CRT_OBSOLETE(LoadLibrary) intptr_t __cdecl _loaddll(_In_z_ char * _Filename);
164 _CRT_OBSOLETE(FreeLibrary) int __cdecl _unloaddll(_In_ intptr_t _Handle);
165 _CRT_OBSOLETE(GetProcAddress) int (__cdecl * __cdecl _getdllprocaddr(_In_ intptr_t _Handle, _In_opt_z_ char * _ProcedureName, _In_ intptr_t _Ordinal))(void);
166
167 /* --------- The preceding functions are OBSOLETE --------- */
168
169
170 #ifdef  _DECL_DLLMAIN
171 /*
172  * Declare DLL notification (initialization/termination) routines
173  *          The preferred method is for the user to provide DllMain() which will
174  *          be called automatically by the DLL entry point defined by the C run-
175  *          time library code.  If the user wants to define the DLL entry point
176  *          routine, the user's entry point must call _CRT_INIT on all types of
177  *          notifications, as the very first thing on attach notifications and
178  *          as the very last thing on detach notifications.
179  */
180 #ifdef  _WINDOWS_           /* Use types from WINDOWS.H */
181 BOOL WINAPI DllMain(_In_ HANDLE _HDllHandle, _In_ DWORD _Reason, _In_opt_ LPVOID _Reserved);
182 BOOL WINAPI _CRT_INIT(_In_ HANDLE _HDllHandle, _In_ DWORD _Reason, _In_opt_ LPVOID _Reserved);
183 BOOL WINAPI _wCRT_INIT(_In_ HANDLE _HDllHandle, _In_ DWORD _Reason, _In_opt_ LPVOID _Reserved);
184 extern BOOL (WINAPI * const _pRawDllMain)(HANDLE, DWORD, LPVOID);
185 #else
186 int __stdcall DllMain(_In_ void * _HDllHandle, _In_ unsigned _Reason, _In_opt_ void * _Reserved);
187 int __stdcall _CRT_INIT(_In_ void * _HDllHandle, _In_ unsigned _Reason, _In_opt_ void * _Reserved);
188 int __stdcall _wCRT_INIT(_In_ void * _HDllHandle, _In_ unsigned _Reason, _In_opt_ void * _Reserved);
189 extern int (__stdcall * const _pRawDllMain)(void *, unsigned, void *);
190 #endif  /* _WINDOWS_ */
191 #endif
192
193 #if        !__STDC__
194
195 /* Non-ANSI names for compatibility */
196
197 #define P_WAIT                _P_WAIT
198 #define P_NOWAIT             _P_NOWAIT
199 #define P_OVERLAY           _P_OVERLAY
200 #define OLD_P_OVERLAY     _OLD_P_OVERLAY
201 #define P_NOWAITO           _P_NOWAITO
202 #define P_DETACH             _P_DETACH
203 #define WAIT_CHILD          _WAIT_CHILD
204 #define WAIT_GRANDCHILD _WAIT_GRANDCHILD
205
206 /* current declarations */
Lines 207 ... 216 are skipped.
217 _CRT_NONSTDC_DEPRECATE(_spawnle) _CRTIMP intptr_t __cdecl spawnle(_In_ int, _In_z_ const char * _Filename, _In_z_ const char * _ArgList, ...);
218 _CRT_NONSTDC_DEPRECATE(_spawnlp) _CRTIMP intptr_t __cdecl spawnlp(_In_ int, _In_z_ const char * _Filename, _In_z_ const char * _ArgList, ...);
219 _CRT_NONSTDC_DEPRECATE(_spawnlpe) _CRTIMP intptr_t __cdecl spawnlpe(_In_ int, _In_z_ const char * _Filename, _In_z_ const char * _ArgList, ...);
220 _CRT_NONSTDC_DEPRECATE(_spawnv) _CRTIMP intptr_t __cdecl spawnv(_In_ int, _In_z_ const char * _Filename, _In_z_ const char * const * _ArgList);
221 _CRT_NONSTDC_DEPRECATE(_spawnve) _CRTIMP intptr_t __cdecl spawnve(_In_ int, _In_z_ const char * _Filename, _In_z_ const char * const * _ArgList,
222              _In_opt_z_ const char * const * _Env);
223 _CRT_NONSTDC_DEPRECATE(_spawnvp) _CRTIMP intptr_t __cdecl spawnvp(_In_ int, _In_z_ const char * _Filename, _In_z_ const char * const * _ArgList);
224 _CRT_NONSTDC_DEPRECATE(_spawnvpe) _CRTIMP intptr_t __cdecl spawnvpe(_In_ int, _In_z_ const char * _Filename, _In_z_ const char * const * _ArgList,
225              _In_opt_z_ const char * const * _Env);
226
227 _CRT_NONSTDC_DEPRECATE(_getpid) _CRTIMP int __cdecl getpid(void);
228
229 #endif  /* __STDC__ */
230
231 #ifdef  __cplusplus
232 }
233 #endif
234
235 #endif  /* _POSIX_ */
236
237 #endif  /* _INC_PROCESS */
238