ReactOS 0.4.16-dev-2104-gb84fa49
process.h File Reference
#include <corecrt_startup.h>
#include <corecrt_wprocess.h>
Include dependency graph for process.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define _P_WAIT   0
 
#define _P_NOWAIT   1
 
#define _P_OVERLAY   2
 
#define _P_NOWAITO   3
 
#define _P_DETACH   4
 
#define _WAIT_CHILD   0
 
#define _WAIT_GRANDCHILD   1
 
#define P_WAIT   _P_WAIT
 
#define P_NOWAIT   _P_NOWAIT
 
#define P_OVERLAY   _P_OVERLAY
 
#define P_NOWAITO   _P_NOWAITO
 
#define P_DETACH   _P_DETACH
 
#define WAIT_CHILD   _WAIT_CHILD
 
#define WAIT_GRANDCHILD   _WAIT_GRANDCHILD
 
#define execv   _execv
 
#define execve   _execve
 
#define execvp   _execvp
 
#define execvpe   _execvpe
 
#define execl   _execl
 
#define execle   _execle
 
#define execlp   _execlp
 
#define execlpe   _execlpe
 
#define spawnl   _spawnl
 
#define spawnle   _spawnle
 
#define spawnlp   _spawnlp
 
#define spawnlpe   _spawnlpe
 

Typedefs

typedef void(__cdecl_beginthread_start_routine_t) (void *)
 
typedef unsigned int(__stdcall_beginthreadex_start_routine_t) (void *)
 

Functions

_ACRTIMP uintptr_t __cdecl _beginthread (_beginthread_start_routine_t, unsigned int, void *)
 
_ACRTIMP uintptr_t __cdecl _beginthreadex (void *, unsigned int, _beginthreadex_start_routine_t, void *, unsigned int, unsigned int *)
 
_ACRTIMP intptr_t __cdecl _cwait (int *, intptr_t, int)
 
_ACRTIMP DECLSPEC_NORETURN void __cdecl _endthread (void)
 
_ACRTIMP DECLSPEC_NORETURN void __cdecl _endthreadex (unsigned int)
 
_ACRTIMP intptr_t __cdecl _execl (const char *, const char *,...)
 
_ACRTIMP intptr_t __cdecl _execle (const char *, const char *,...)
 
_ACRTIMP intptr_t __cdecl _execlp (const char *, const char *,...)
 
_ACRTIMP intptr_t __cdecl _execlpe (const char *, const char *,...)
 
_ACRTIMP intptr_t __cdecl _execv (const char *, const char *const *)
 
_ACRTIMP intptr_t __cdecl _execve (const char *, const char *const *, const char *const *)
 
_ACRTIMP intptr_t __cdecl _execvp (const char *, const char *const *)
 
_ACRTIMP intptr_t __cdecl _execvpe (const char *, const char *const *, const char *const *)
 
_ACRTIMP int __cdecl _getpid (void)
 
_ACRTIMP intptr_t __cdecl _spawnl (int, const char *, const char *,...)
 
_ACRTIMP intptr_t __cdecl _spawnle (int, const char *, const char *,...)
 
_ACRTIMP intptr_t __cdecl _spawnlp (int, const char *, const char *,...)
 
_ACRTIMP intptr_t __cdecl _spawnlpe (int, const char *, const char *,...)
 
_ACRTIMP intptr_t __cdecl _spawnv (int, const char *, const char *const *)
 
_ACRTIMP intptr_t __cdecl _spawnve (int, const char *, const char *const *, const char *const *)
 
_ACRTIMP intptr_t __cdecl _spawnvp (int, const char *, const char *const *)
 
_ACRTIMP intptr_t __cdecl _spawnvpe (int, const char *, const char *const *, const char *const *)
 
_ACRTIMP void __cdecl _c_exit (void)
 
_ACRTIMP void __cdecl _cexit (void)
 
_ACRTIMP DECLSPEC_NORETURN void __cdecl _exit (int)
 
_ACRTIMP DECLSPEC_NORETURN void __cdecl abort (void)
 Aborts the program.
 
_ACRTIMP DECLSPEC_NORETURN void __cdecl exit (int)
 
_ACRTIMP DECLSPEC_NORETURN void __cdecl quick_exit (int)
 
_ACRTIMP int __cdecl system (const char *)
 
static intptr_t cwait (int *status, intptr_t pid, int action)
 
static int getpid (void)
 
static intptr_t spawnv (int flags, const char *name, const char *const *argv)
 
static intptr_t spawnve (int flags, const char *name, const char *const *argv, const char *const *envv)
 
static intptr_t spawnvp (int flags, const char *name, const char *const *argv)
 
static intptr_t spawnvpe (int flags, const char *name, const char *const *argv, const char *const *envv)
 

Macro Definition Documentation

◆ _P_DETACH

#define _P_DETACH   4

Definition at line 19 of file process.h.

◆ _P_NOWAIT

#define _P_NOWAIT   1

Definition at line 16 of file process.h.

◆ _P_NOWAITO

#define _P_NOWAITO   3

Definition at line 18 of file process.h.

◆ _P_OVERLAY

#define _P_OVERLAY   2

Definition at line 17 of file process.h.

◆ _P_WAIT

#define _P_WAIT   0

Definition at line 15 of file process.h.

◆ _WAIT_CHILD

#define _WAIT_CHILD   0

Definition at line 21 of file process.h.

◆ _WAIT_GRANDCHILD

#define _WAIT_GRANDCHILD   1

Definition at line 22 of file process.h.

◆ execl

#define execl   _execl

Definition at line 97 of file process.h.

◆ execle

#define execle   _execle

Definition at line 98 of file process.h.

◆ execlp

#define execlp   _execlp

Definition at line 99 of file process.h.

◆ execlpe

#define execlpe   _execlpe

Definition at line 100 of file process.h.

◆ execv

#define execv   _execv

Definition at line 82 of file process.h.

◆ execve

#define execve   _execve

Definition at line 83 of file process.h.

◆ execvp

#define execvp   _execvp

Definition at line 84 of file process.h.

◆ execvpe

#define execvpe   _execvpe

Definition at line 85 of file process.h.

◆ P_DETACH

#define P_DETACH   _P_DETACH

Definition at line 71 of file process.h.

◆ P_NOWAIT

#define P_NOWAIT   _P_NOWAIT

Definition at line 68 of file process.h.

◆ P_NOWAITO

#define P_NOWAITO   _P_NOWAITO

Definition at line 70 of file process.h.

◆ P_OVERLAY

#define P_OVERLAY   _P_OVERLAY

Definition at line 69 of file process.h.

◆ P_WAIT

#define P_WAIT   _P_WAIT

Definition at line 67 of file process.h.

◆ spawnl

#define spawnl   _spawnl

Definition at line 101 of file process.h.

◆ spawnle

#define spawnle   _spawnle

Definition at line 102 of file process.h.

◆ spawnlp

#define spawnlp   _spawnlp

Definition at line 103 of file process.h.

◆ spawnlpe

#define spawnlpe   _spawnlpe

Definition at line 104 of file process.h.

◆ WAIT_CHILD

#define WAIT_CHILD   _WAIT_CHILD

Definition at line 73 of file process.h.

◆ WAIT_GRANDCHILD

#define WAIT_GRANDCHILD   _WAIT_GRANDCHILD

Definition at line 74 of file process.h.

Typedef Documentation

◆ _beginthread_start_routine_t

typedef void(__cdecl * _beginthread_start_routine_t) (void *)

Definition at line 28 of file process.h.

◆ _beginthreadex_start_routine_t

typedef unsigned int(__stdcall * _beginthreadex_start_routine_t) (void *)

Definition at line 29 of file process.h.

Function Documentation

◆ _beginthread()

_ACRTIMP uintptr_t __cdecl _beginthread ( _beginthread_start_routine_t  start_address,
unsigned int  stack_size,
void arglist 
)

Definition at line 134 of file thread.c.

138{
139 _beginthread_trampoline_t* trampoline;
141
142 TRACE("(%p, %d, %p)\n", start_address, stack_size, arglist);
143
144 if (!MSVCRT_CHECK_PMT(start_address)) return -1;
145
146 trampoline = malloc(sizeof(*trampoline));
147 if(!trampoline) {
148 *_errno() = EAGAIN;
149 return -1;
150 }
151
153 trampoline, CREATE_SUSPENDED, NULL);
154 if(!thread) {
155 free(trampoline);
157 return -1;
158 }
159
160 trampoline->thread = thread;
161 trampoline->start_address = start_address;
162 trampoline->arglist = arglist;
163
164#if _MSVCR_VER >= 140
165 if(!GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
166 (void*)start_address, &trampoline->module))
167 {
168 trampoline->module = NULL;
169 WARN("failed to get module for the start_address: %lu\n", GetLastError());
170 }
171#endif
172
173 if(ResumeThread(thread) == -1) {
174#if _MSVCR_VER >= 140
175 FreeLibrary(trampoline->module);
176#endif
177 free(trampoline);
178 *_errno() = EAGAIN;
179 return -1;
180 }
181
182 return (uintptr_t)thread;
183}
#define WARN(fmt,...)
Definition: precomp.h:61
static HANDLE thread
Definition: service.c:33
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
#define FreeLibrary(x)
Definition: compat.h:748
BOOL WINAPI GetModuleHandleExW(IN DWORD dwFlags, IN LPCWSTR lpwModuleName OPTIONAL, OUT HMODULE *phModule)
Definition: loader.c:866
DWORD WINAPI ResumeThread(IN HANDLE hThread)
Definition: thread.c:567
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
int *CDECL _errno(void)
Definition: errno.c:215
unsigned int uintptr_t
Definition: corecrt.h:185
#define EAGAIN
Definition: errno.h:34
#define MSVCRT_CHECK_PMT(x)
Definition: msvcrt.h:378
static DWORD CALLBACK _beginthread_trampoline(LPVOID arg)
Definition: thread.c:115
#define msvcrt_set_errno
Definition: heap.c:50
va_lists_t arglist[FMT_ARGMAX+1]
Definition: format.c:284
#define TRACE(s)
Definition: solgame.cpp:4
_beginthread_start_routine_t start_address
Definition: thread.c:31
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define CREATE_SUSPENDED
Definition: winbase.h:182

Referenced by init(), main(), runProg(), ServiceMain(), StartDefragThread(), test_thread_handle_close(), test_thread_invalid_params(), test_thread_library_reference(), WndProc(), and xmlGetGlobalState().

◆ _beginthreadex()

_ACRTIMP uintptr_t __cdecl _beginthreadex ( void security,
unsigned int  stack_size,
_beginthreadex_start_routine_t  start_address,
void arglist,
unsigned int  initflag,
unsigned int thrdaddr 
)

Definition at line 207 of file thread.c.

214{
215 _beginthread_trampoline_t* trampoline;
217
218 TRACE("(%p, %d, %p, %p, %d, %p)\n", security, stack_size, start_address, arglist, initflag, thrdaddr);
219
220 /* FIXME: may use different errno / return values */
221 if (!MSVCRT_CHECK_PMT(start_address)) return 0;
222
223 if (!(trampoline = malloc(sizeof(*trampoline))))
224 return 0;
225
226 trampoline->thread = INVALID_HANDLE_VALUE;
227 trampoline->start_address_ex = start_address;
228 trampoline->arglist = arglist;
229
230#if _MSVCR_VER >= 140
231 if(!GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
232 (void*)start_address, &trampoline->module))
233 {
234 trampoline->module = NULL;
235 WARN("failed to get module for the start_address: %lu\n", GetLastError());
236 }
237#endif
238
240 trampoline, initflag, (DWORD *)thrdaddr);
241 if(!thread) {
242#if _MSVCR_VER >= 140
243 FreeLibrary(trampoline->module);
244#endif
245 free(trampoline);
247 return 0;
248 }
249
250 return (uintptr_t)thread;
251}
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
static DWORD CALLBACK _beginthreadex_trampoline(LPVOID arg)
Definition: thread.c:188
unsigned long DWORD
Definition: ntddk_ex.h:95
_beginthreadex_start_routine_t start_address_ex
Definition: thread.c:32

Referenced by clnt_vc_create(), CDirectoryWatcher::CreateAPCThread(), DialogProc_0(), DialogProc_1(), CIconWatcher::Initialize(), InitProgressDialog(), nfs41_delegation_recall(), nfs41_session_set_lease(), CAutoComplete::OnAutoCompStart(), OpenPropSheet(), pattern_fork(), ProgressDlg::ProcessWindowMessage(), CDeviceView::Refresh(), CZipCreator::runThread(), ServiceStart(), START_TEST(), StartWatchGUI(), CDownloadManager::StartWorkerThread(), test_file_inherit(), test_thread_handle_close(), test_thread_invalid_params(), test_thread_library_reference(), test_thread_setlocale(), and test_thread_suspended().

◆ _c_exit()

_ACRTIMP void __cdecl _c_exit ( void  )

Definition at line 327 of file exit.c.

328{
329 TRACE("(void)\n");
330 /* All cleanup is done on DLL detach; Return to caller */
331}

◆ _cexit()

_ACRTIMP void __cdecl _cexit ( void  )

Definition at line 336 of file exit.c.

337{
338 TRACE("(void)\n");
339 LOCK_EXIT;
340 call_atexit();
342}
#define LOCK_EXIT
Definition: exit.c:32
#define UNLOCK_EXIT
Definition: exit.c:33
static void call_atexit(void)
Definition: exit.c:144

◆ _cwait()

_ACRTIMP intptr_t __cdecl _cwait ( int status,
intptr_t  pid,
int  action 
)

Definition at line 362 of file process.c.

363{
364 HANDLE hPid = (HANDLE)pid;
365 int doserrno;
366
367 if (!WaitForSingleObject(hPid, INFINITE))
368 {
369 if (status)
370 {
371 DWORD stat;
372 GetExitCodeProcess(hPid, &stat);
373 *status = (int)stat;
374 }
375 return pid;
376 }
377 doserrno = GetLastError();
378
379 if (doserrno == ERROR_INVALID_HANDLE)
380 {
381 *_errno() = ECHILD;
382 *__doserrno() = doserrno;
383 }
384 else
385 msvcrt_set_errno(doserrno);
386
387 return status ? *status = -1 : -1;
388}
#define stat
Definition: acwin.h:99
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
BOOL WINAPI GetExitCodeProcess(IN HANDLE hProcess, IN LPDWORD lpExitCode)
Definition: proc.c:1168
__msvcrt_ulong *CDECL __doserrno(void)
Definition: errno.c:223
#define ECHILD
Definition: errno.h:33
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
#define INFINITE
Definition: serial.h:102
Definition: stat.h:66
Definition: ps.c:97
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
PVOID HANDLE
Definition: typedefs.h:73
_In_ ULONG_PTR _In_ ULONG _Out_ ULONG_PTR * pid
Definition: winddi.h:3837

Referenced by _pclose(), _wsystem(), cwait(), and system().

◆ _endthread()

Definition at line 73 of file thread.c.

74{
76
77 TRACE("(void)\n");
78
80 if (tls && tls->handle != INVALID_HANDLE_VALUE)
81 {
82 CloseHandle(tls->handle);
83 tls->handle = INVALID_HANDLE_VALUE;
84 } else
85 WARN("tls=%p tls->handle=%p\n", tls, tls ? tls->handle : INVALID_HANDLE_VALUE);
86
87 _endthreadex(0);
88}
#define CloseHandle
Definition: compat.h:739
LPVOID WINAPI TlsGetValue(IN DWORD Index)
Definition: thread.c:1240
DWORD msvcrt_tls_index
Definition: main.c:29
void CDECL _endthreadex(unsigned int retval)
Definition: thread.c:93
static DWORD tls
Definition: sock.c:229

Referenced by DefragThread(), init(), processRequest(), test_thread_func(), and test_thread_func_ex().

◆ _endthreadex()

_ACRTIMP DECLSPEC_NORETURN void __cdecl _endthreadex ( unsigned int  retval)

Definition at line 93 of file thread.c.

95{
96 TRACE("(%d)\n", retval);
97
98#if _MSVCR_VER >= 140
99 {
101
102 if (tls && tls->module != NULL)
104 else
105 WARN("tls=%p tls->module=%p\n", tls, tls ? tls->module : NULL);
106 }
107#endif
108
110}
VOID WINAPI FreeLibraryAndExitThread(HMODULE hLibModule, DWORD dwExitCode)
Definition: loader.c:507
VOID WINAPI ExitThread(IN DWORD uExitCode)
Definition: thread.c:365
int retval
Definition: wcstombs.cpp:91

Referenced by ActionThread(), and test_thread_func().

◆ _execl()

_ACRTIMP intptr_t __cdecl _execl ( const char name,
const char arg0,
  ... 
)

Definition at line 417 of file process.c.

418{
419 va_list ap;
420 wchar_t *nameW, *args;
422
423 if (!(nameW = wstrdupa_utf8(name))) return -1;
424
425 va_start(ap, arg0);
426 args = msvcrt_valisttos_aw(arg0, ap, ' ');
427 va_end(ap);
428
430
431 free(nameW);
432 free(args);
433 return ret;
434}
static const WCHAR nameW[]
Definition: main.c:49
int intptr_t
Definition: corecrt.h:176
#define _P_OVERLAY
Definition: process.h:17
#define va_end(v)
Definition: stdarg.h:28
#define va_start(v, l)
Definition: stdarg.h:26
char * va_list
Definition: vadefs.h:50
static wchar_t * wstrdupa_utf8(const char *str)
Definition: msvcrt.h:440
static intptr_t msvcrt_spawn(int flags, const wchar_t *exe, wchar_t *cmdline, wchar_t *env, int use_path)
Definition: process.c:135
static wchar_t * msvcrt_valisttos_aw(const char *arg0, va_list alist, wchar_t delim)
Definition: process.c:314
return ret
Definition: mutex.c:146
#define args
Definition: format.c:66
Definition: match.c:390
Definition: name.c:39
void int int ULONGLONG int va_list * ap
Definition: winesup.h:36

◆ _execle()

_ACRTIMP intptr_t __cdecl _execle ( const char name,
const char arg0,
  ... 
)

Definition at line 468 of file process.c.

469{
470 va_list ap;
471 wchar_t *nameW, *args, *envs = NULL;
472 const char * const *envp;
474
475 if (!(nameW = wstrdupa_utf8(name))) return -1;
476
477 va_start(ap, arg0);
478 args = msvcrt_valisttos_aw(arg0, ap, ' ');
479 va_end(ap);
480
481 va_start(ap, arg0);
482 while (va_arg( ap, char * ) != NULL) /*nothing*/;
483 envp = va_arg( ap, const char * const * );
484 if (envp) envs = msvcrt_argvtos_aw(envp, TRUE);
485 va_end(ap);
486
487 ret = msvcrt_spawn(_P_OVERLAY, nameW, args, envs, 0);
488
489 free(nameW);
490 free(args);
491 free(envs);
492 return ret;
493}
#define TRUE
Definition: types.h:120
#define va_arg(v, l)
Definition: stdarg.h:27
static wchar_t * msvcrt_argvtos_aw(const char *const *arg, BOOL env)
Definition: process.c:236

◆ _execlp()

_ACRTIMP intptr_t __cdecl _execlp ( const char name,
const char arg0,
  ... 
)

Definition at line 522 of file process.c.

523{
524 va_list ap;
525 wchar_t *nameW, *args;
527
528 if (!(nameW = wstrdupa_utf8(name))) return -1;
529
530 va_start(ap, arg0);
531 args = msvcrt_valisttos_aw(arg0, ap, ' ');
532 va_end(ap);
533
535
536 free(nameW);
537 free(args);
538 return ret;
539}

◆ _execlpe()

_ACRTIMP intptr_t __cdecl _execlpe ( const char name,
const char arg0,
  ... 
)

Definition at line 573 of file process.c.

574{
575 va_list ap;
576 wchar_t *nameW, *args, *envs = NULL;
577 const char * const *envp;
579
580 if (!(nameW = wstrdupa_utf8(name))) return -1;
581
582 va_start(ap, arg0);
583 args = msvcrt_valisttos_aw(arg0, ap, ' ');
584 va_end(ap);
585
586 va_start(ap, arg0);
587 while (va_arg( ap, char * ) != NULL) /*nothing*/;
588 envp = va_arg( ap, const char * const * );
589 if (envp) envs = msvcrt_argvtos_aw(envp, TRUE);
590 va_end(ap);
591
592 ret = msvcrt_spawn(_P_OVERLAY, nameW, args, envs, 1);
593
594 free(nameW);
595 free(args);
596 free(envs);
597 return ret;
598}

◆ _execv()

_ACRTIMP intptr_t __cdecl _execv ( const char name,
const char *const argv 
)

Definition at line 616 of file process.c.

617{
618 return _spawnve(_P_OVERLAY, name, argv, NULL);
619}
intptr_t CDECL _spawnve(int flags, const char *name, const char *const *argv, const char *const *envv)
Definition: process.c:900
#define argv
Definition: mplay32.c:18

◆ _execve()

_ACRTIMP intptr_t __cdecl _execve ( const char name,
const char *const argv,
const char *const envv 
)

Definition at line 637 of file process.c.

638{
639 return _spawnve(_P_OVERLAY, name, argv, envv);
640}

◆ _execvp()

_ACRTIMP intptr_t __cdecl _execvp ( const char name,
const char *const argv 
)

Definition at line 679 of file process.c.

680{
681 return _execvpe(name, argv, NULL);
682}
intptr_t CDECL _execvpe(const char *name, const char *const *argv, const char *const *envv)
Definition: process.c:658

◆ _execvpe()

_ACRTIMP intptr_t __cdecl _execvpe ( const char name,
const char *const argv,
const char *const envv 
)

Definition at line 658 of file process.c.

659{
660 return _spawnvpe(_P_OVERLAY, name, argv, envv);
661}
intptr_t CDECL _spawnvpe(int flags, const char *name, const char *const *argv, const char *const *envv)
Definition: process.c:967

Referenced by _execvp().

◆ _exit()

_ACRTIMP DECLSPEC_NORETURN void __cdecl _exit ( int  exitcode)

Definition at line 187 of file exit.c.

188{
189 TRACE("(%d)\n", exitcode);
190 ExitProcess(exitcode);
191}
VOID WINAPI ExitProcess(IN UINT uExitCode)
Definition: proc.c:1489

Referenced by _Exit().

◆ _getpid()

_ACRTIMP int __cdecl _getpid ( void  )

Definition at line 1360 of file process.c.

1361{
1362 return GetCurrentProcessId();
1363}
DWORD WINAPI GetCurrentProcessId(void)
Definition: proc.c:1158

Referenced by clnt_dg_create(), and getpid().

◆ _spawnl()

_ACRTIMP intptr_t __cdecl _spawnl ( int  flags,
const char name,
const char arg0,
  ... 
)

Definition at line 711 of file process.c.

712{
713 va_list ap;
714 wchar_t *nameW, *args;
716
717 if (!(nameW = wstrdupa_utf8(name))) return -1;
718
719 va_start(ap, arg0);
720 args = msvcrt_valisttos_aw(arg0, ap, ' ');
721 va_end(ap);
722
724
725 free(nameW);
726 free(args);
727 return ret;
728}
GLbitfield flags
Definition: glext.h:7161

◆ _spawnle()

_ACRTIMP intptr_t __cdecl _spawnle ( int  flags,
const char name,
const char arg0,
  ... 
)

Definition at line 762 of file process.c.

763{
764 va_list ap;
765 wchar_t *nameW, *args, *envs = NULL;
766 const char * const *envp;
768
769 if (!(nameW = wstrdupa_utf8(name))) return -1;
770
771 va_start(ap, arg0);
772 args = msvcrt_valisttos_aw(arg0, ap, ' ');
773 va_end(ap);
774
775 va_start(ap, arg0);
776 while (va_arg( ap, char * ) != NULL) /*nothing*/;
777 envp = va_arg( ap, const char * const * );
778 if (envp) envs = msvcrt_argvtos_aw(envp, TRUE);
779 va_end(ap);
780
781 ret = msvcrt_spawn(flags, nameW, args, envs, 0);
782
783 free(nameW);
784 free(args);
785 free(envs);
786 return ret;
787}

Referenced by test_utf8().

◆ _spawnlp()

_ACRTIMP intptr_t __cdecl _spawnlp ( int  flags,
const char name,
const char arg0,
  ... 
)

Definition at line 816 of file process.c.

817{
818 va_list ap;
819 wchar_t *nameW, *args;
821
822 if (!(nameW = wstrdupa_utf8(name))) return -1;
823
824 va_start(ap, arg0);
825 args = msvcrt_valisttos_aw(arg0, ap, ' ');
826 va_end(ap);
827
829
830 free(nameW);
831 free(args);
832 return ret;
833}

◆ _spawnlpe()

_ACRTIMP intptr_t __cdecl _spawnlpe ( int  flags,
const char name,
const char arg0,
  ... 
)

Definition at line 867 of file process.c.

868{
869 va_list ap;
870 wchar_t *nameW, *args, *envs = NULL;
871 const char * const *envp;
873
874 if (!(nameW = wstrdupa_utf8(name))) return -1;
875
876 va_start(ap, arg0);
877 args = msvcrt_valisttos_aw(arg0, ap, ' ');
878 va_end(ap);
879
880 va_start(ap, arg0);
881 while (va_arg( ap, char * ) != NULL) /*nothing*/;
882 envp = va_arg( ap, const char * const * );
883 if (envp) envs = msvcrt_argvtos_aw(envp, TRUE);
884 va_end(ap);
885
886 ret = msvcrt_spawn(flags, nameW, args, envs, 1);
887
888 free(nameW);
889 free(args);
890 free(envs);
891 return ret;
892}

◆ _spawnv()

_ACRTIMP intptr_t __cdecl _spawnv ( int  flags,
const char name,
const char *const argv 
)

Definition at line 946 of file process.c.

947{
948 return _spawnve(flags, name, argv, NULL);
949}

Referenced by spawnv().

◆ _spawnve()

_ACRTIMP intptr_t __cdecl _spawnve ( int  flags,
const char name,
const char *const argv,
const char *const envv 
)

Definition at line 900 of file process.c.

902{
903 wchar_t *nameW, *args, *envs;
905
906 if (!(nameW = wstrdupa_utf8(name))) return -1;
907
909 envs = msvcrt_argvtos_aw(envv, TRUE);
910
911 ret = msvcrt_spawn(flags, nameW, args, envs, 0);
912
913 free(nameW);
914 free(args);
915 free(envs);
916 return ret;
917}
#define FALSE
Definition: types.h:117

Referenced by _execv(), _execve(), _spawnv(), _tspawnve(), and spawnve().

◆ _spawnvp()

_ACRTIMP intptr_t __cdecl _spawnvp ( int  flags,
const char name,
const char *const argv 
)

Definition at line 1013 of file process.c.

1014{
1015 return _spawnvpe(flags, name, argv, NULL);
1016}

Referenced by spawnvp(), strarray_spawn(), test_file_inherit(), and test_pipes().

◆ _spawnvpe()

_ACRTIMP intptr_t __cdecl _spawnvpe ( int  flags,
const char name,
const char *const argv,
const char *const envv 
)

Definition at line 967 of file process.c.

969{
970 wchar_t *nameW, *args, *envs;
972
973 if (!(nameW = wstrdupa_utf8(name))) return -1;
974
976 envs = msvcrt_argvtos_aw(envv, TRUE);
977
978 ret = msvcrt_spawn(flags, nameW, args, envs, 1);
979
980 free(nameW);
981 free(args);
982 free(envs);
983 return ret;
984}

Referenced by _execvpe(), _spawnvp(), _tspawnvpe(), and spawnvpe().

◆ abort()

Aborts the program.

Note
The function does not return.
Todo:
unimplemented

Definition at line 252 of file exit.c.

253{
254 TRACE("()\n");
255
256#if (_MSVCR_VER > 0 && _MSVCR_VER < 100) || _MSVCR_VER == 120 || defined(_DEBUG)
257 if (MSVCRT_abort_behavior & _WRITE_ABORT_MSG)
258 {
261 {
262 DoMessageBox("Runtime error!", "abnormal program termination");
263 }
264 else
265 _cputs("\nabnormal program termination\n");
266 }
267#endif
268 raise(SIGABRT);
269 /* in case raise() returns */
270 _exit(3);
271}
int CDECL _cputs(const char *str)
Definition: console.c:78
int CDECL raise(int sig)
Definition: except.c:682
static void DoMessageBox(const char *lead, const char *message)
Definition: exit.c:220
int MSVCRT_app_type
Definition: data.c:59
void CDECL _exit(int exitcode)
Definition: exit.c:187
static int MSVCRT_error_mode
Definition: exit.c:58
#define SIGABRT
Definition: signal.h:31
#define _OUT_TO_MSGBOX
Definition: stdlib.h:75
#define _OUT_TO_DEFAULT
Definition: stdlib.h:73
#define _WRITE_ABORT_MSG
Definition: stdlib.h:79

◆ cwait()

static intptr_t cwait ( int status,
intptr_t  pid,
int  action 
)
inlinestatic

Definition at line 76 of file process.h.

76{ return _cwait(status, pid, action); }
_ACRTIMP intptr_t __cdecl _cwait(int *, intptr_t, int)
Definition: process.c:362
action
Definition: namespace.c:707

◆ exit()

Definition at line 364 of file exit.c.

365{
367 void (WINAPI *pCorExitProcess)(int);
368
369 TRACE("(%d)\n",exitcode);
370 _cexit();
371
372 hmscoree = GetModuleHandleW(L"mscoree");
373
374 if (hmscoree)
375 {
376 pCorExitProcess = (void*)GetProcAddress(hmscoree, "CorExitProcess");
377
378 if (pCorExitProcess)
379 pCorExitProcess(exitcode);
380 }
381
382 ExitProcess(exitcode);
383}
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
void CDECL _cexit(void)
Definition: exit.c:336
#define L(x)
Definition: resources.c:13
static HMODULE hmscoree
Definition: fusion.c:24
#define WINAPI
Definition: msvc.h:6

◆ getpid()

static int getpid ( void  )
inlinestatic

Definition at line 77 of file process.h.

77{ return _getpid(); }
_ACRTIMP int __cdecl _getpid(void)
Definition: process.c:1360

◆ quick_exit()

_ACRTIMP DECLSPEC_NORETURN void __cdecl quick_exit ( int  return_code)

Definition at line 304 of file exit.cpp.

305{
308}
static void __cdecl common_exit(int const return_code, _crt_exit_cleanup_mode const cleanup_mode, _crt_exit_return_mode const return_mode)
Definition: exit.cpp:175
#define UNREACHABLE
@ _crt_exit_quick_cleanup
@ _crt_exit_terminate_process

Referenced by test_call_quick_exit().

◆ spawnv()

static intptr_t spawnv ( int  flags,
const char name,
const char *const argv 
)
inlinestatic

Definition at line 78 of file process.h.

78{ return _spawnv(flags, name, argv); }
_ACRTIMP intptr_t __cdecl _spawnv(int, const char *, const char *const *)
Definition: process.c:946

◆ spawnve()

static intptr_t spawnve ( int  flags,
const char name,
const char *const argv,
const char *const envv 
)
inlinestatic

Definition at line 79 of file process.h.

79{ return _spawnve(flags, name, argv, envv); }
_ACRTIMP intptr_t __cdecl _spawnve(int, const char *, const char *const *, const char *const *)
Definition: process.c:900

◆ spawnvp()

static intptr_t spawnvp ( int  flags,
const char name,
const char *const argv 
)
inlinestatic

Definition at line 80 of file process.h.

80{ return _spawnvp(flags, name, argv); }
_ACRTIMP intptr_t __cdecl _spawnvp(int, const char *, const char *const *)
Definition: process.c:1013

◆ spawnvpe()

static intptr_t spawnvpe ( int  flags,
const char name,
const char *const argv,
const char *const envv 
)
inlinestatic

Definition at line 81 of file process.h.

81{ return _spawnvpe(flags, name, argv, envv); }
_ACRTIMP intptr_t __cdecl _spawnvpe(int, const char *, const char *const *, const char *const *)
Definition: process.c:967

◆ system()