ReactOS 0.4.16-dev-2104-gb84fa49
process.c File Reference
#include <fcntl.h>
#include <io.h>
#include <process.h>
#include <stdarg.h>
#include "msvcrt.h"
#include <winnls.h>
#include "mtdll.h"
#include "wine/debug.h"
Include dependency graph for process.c:

Go to the source code of this file.

Classes

struct  popen_handle
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (msvcrt)
 
static void msvcrt_search_executable (const wchar_t *name, wchar_t *fullname, int use_path)
 
static intptr_t msvcrt_spawn (int flags, const wchar_t *exe, wchar_t *cmdline, wchar_t *env, int use_path)
 
static wchar_tmsvcrt_argvtos (const wchar_t *const *arg, wchar_t delim)
 
static wchar_tmsvcrt_argvtos_aw (const char *const *arg, BOOL env)
 
static wchar_tmsvcrt_valisttos (const wchar_t *arg0, va_list alist, wchar_t delim)
 
static wchar_tmsvcrt_valisttos_aw (const char *arg0, va_list alist, wchar_t delim)
 
static wchar_tmsvcrt_get_comspec (void)
 
intptr_t CDECL _cwait (int *status, intptr_t pid, int action)
 
intptr_t WINAPIV _wexecl (const wchar_t *name, const wchar_t *arg0,...)
 
intptr_t WINAPIV _execl (const char *name, const char *arg0,...)
 
intptr_t WINAPIV _wexecle (const wchar_t *name, const wchar_t *arg0,...)
 
intptr_t WINAPIV _execle (const char *name, const char *arg0,...)
 
intptr_t WINAPIV _wexeclp (const wchar_t *name, const wchar_t *arg0,...)
 
intptr_t WINAPIV _execlp (const char *name, const char *arg0,...)
 
intptr_t WINAPIV _wexeclpe (const wchar_t *name, const wchar_t *arg0,...)
 
intptr_t WINAPIV _execlpe (const char *name, const char *arg0,...)
 
intptr_t CDECL _wexecv (const wchar_t *name, const wchar_t *const *argv)
 
intptr_t CDECL _execv (const char *name, const char *const *argv)
 
intptr_t CDECL _wexecve (const wchar_t *name, const wchar_t *const *argv, const wchar_t *const *envv)
 
intptr_t CDECL _execve (const char *name, const char *const *argv, const char *const *envv)
 
intptr_t CDECL _wexecvpe (const wchar_t *name, const wchar_t *const *argv, const wchar_t *const *envv)
 
intptr_t CDECL _execvpe (const char *name, const char *const *argv, const char *const *envv)
 
intptr_t CDECL _wexecvp (const wchar_t *name, const wchar_t *const *argv)
 
intptr_t CDECL _execvp (const char *name, const char *const *argv)
 
intptr_t WINAPIV _wspawnl (int flags, const wchar_t *name, const wchar_t *arg0,...)
 
intptr_t WINAPIV _spawnl (int flags, const char *name, const char *arg0,...)
 
intptr_t WINAPIV _wspawnle (int flags, const wchar_t *name, const wchar_t *arg0,...)
 
intptr_t WINAPIV _spawnle (int flags, const char *name, const char *arg0,...)
 
intptr_t WINAPIV _wspawnlp (int flags, const wchar_t *name, const wchar_t *arg0,...)
 
intptr_t WINAPIV _spawnlp (int flags, const char *name, const char *arg0,...)
 
intptr_t WINAPIV _wspawnlpe (int flags, const wchar_t *name, const wchar_t *arg0,...)
 
intptr_t WINAPIV _spawnlpe (int flags, const char *name, const char *arg0,...)
 
intptr_t CDECL _spawnve (int flags, const char *name, const char *const *argv, const char *const *envv)
 
intptr_t CDECL _wspawnve (int flags, const wchar_t *name, const wchar_t *const *argv, const wchar_t *const *envv)
 
intptr_t CDECL _spawnv (int flags, const char *name, const char *const *argv)
 
intptr_t CDECL _wspawnv (int flags, const wchar_t *name, const wchar_t *const *argv)
 
intptr_t CDECL _spawnvpe (int flags, const char *name, const char *const *argv, const char *const *envv)
 
intptr_t CDECL _wspawnvpe (int flags, const wchar_t *name, const wchar_t *const *argv, const wchar_t *const *envv)
 
intptr_t CDECL _spawnvp (int flags, const char *name, const char *const *argv)
 
intptr_t CDECL _wspawnvp (int flags, const wchar_t *name, const wchar_t *const *argv)
 
void msvcrt_free_popen_data (void)
 
FILE *CDECL _wpopen (const wchar_t *command, const wchar_t *mode)
 
FILE *CDECL _popen (const char *command, const char *mode)
 
int CDECL _pclose (FILE *file)
 
int CDECL _wsystem (const wchar_t *cmd)
 
int CDECL system (const char *cmd)
 
intptr_t CDECL _loaddll (const char *dllname)
 
int CDECL _unloaddll (intptr_t dll)
 
void *CDECL _getdllprocaddr (intptr_t dll, const char *name, int ordinal)
 
int CDECL _getpid (void)
 

Variables

static struct popen_handlepopen_handles
 
static DWORD popen_handles_size
 

Function Documentation

◆ _cwait()

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
int *CDECL _errno(void)
Definition: errno.c:215
#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
unsigned long DWORD
Definition: ntddk_ex.h:95
#define msvcrt_set_errno
Definition: heap.c:50
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
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
_In_ ULONG_PTR _In_ ULONG _Out_ ULONG_PTR * pid
Definition: winddi.h:3837

◆ _execl()

intptr_t WINAPIV _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
#define free
Definition: debug_ros.c:5
#define NULL
Definition: types.h:112
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()

intptr_t WINAPIV _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()

intptr_t WINAPIV _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()

intptr_t WINAPIV _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()

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()

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()

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()

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().

◆ _getdllprocaddr()

void *CDECL _getdllprocaddr ( intptr_t  dll,
const char name,
int  ordinal 
)

Definition at line 1346 of file process.c.

1347{
1348 if (name)
1349 {
1350 if (ordinal != -1) return NULL;
1351 return GetProcAddress( (HMODULE)dll, name );
1352 }
1353 if (HIWORD(ordinal)) return NULL;
1354 return GetProcAddress( (HMODULE)dll, (LPCSTR)(ULONG_PTR)ordinal );
1355}
#define GetProcAddress(x, y)
Definition: compat.h:753
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define HIWORD(l)
Definition: typedefs.h:247
const char * LPCSTR
Definition: xmlstorage.h:183

◆ _getpid()

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

◆ _loaddll()

intptr_t CDECL _loaddll ( const char dllname)

Definition at line 1317 of file process.c.

1318{
1319 wchar_t *dllnameW = NULL;
1320 intptr_t ret;
1321
1322 if (dllname && !(dllnameW = wstrdupa_utf8(dllname))) return 0;
1323 ret = (intptr_t)LoadLibraryW(dllnameW);
1324 free(dllnameW);
1325 return ret;
1326}
#define LoadLibraryW(x)
Definition: compat.h:747

◆ _pclose()

int CDECL _pclose ( FILE file)

Definition at line 1212 of file process.c.

1213{
1214 HANDLE h;
1215 DWORD i;
1216
1217 if (!MSVCRT_CHECK_PMT(file != NULL)) return -1;
1218
1220 for(i=0; i<popen_handles_size; i++)
1221 {
1222 if (popen_handles[i].f == file)
1223 break;
1224 }
1225 if(i == popen_handles_size)
1226 {
1228 *_errno() = EBADF;
1229 return -1;
1230 }
1231
1232 h = popen_handles[i].proc;
1233 popen_handles[i].f = NULL;
1235
1236 fclose(file);
1238 {
1240 CloseHandle(h);
1241 return -1;
1242 }
1243
1244 CloseHandle(h);
1245 return i;
1246}
#define CloseHandle
Definition: compat.h:739
int CDECL fclose(FILE *file)
Definition: file.c:3757
#define EBADF
Definition: errno.h:32
void CDECL _lock(int locknum)
Definition: lock.c:85
void CDECL _unlock(int locknum)
Definition: lock.c:114
#define MSVCRT_CHECK_PMT(x)
Definition: msvcrt.h:378
#define _POPEN_LOCK
Definition: mtdll.h:40
static DWORD popen_handles_size
Definition: process.c:1032
static struct popen_handle * popen_handles
GLfloat f
Definition: glext.h:7540
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
Definition: fci.c:127
#define WAIT_FAILED
Definition: winbase.h:390

◆ _popen()

FILE *CDECL _popen ( const char command,
const char mode 
)

Definition at line 1185 of file process.c.

1186{
1187 FILE *ret;
1188 wchar_t *cmdW, *modeW;
1189
1190 TRACE("(command=%s, mode=%s)\n", debugstr_a(command), debugstr_a(mode));
1191
1192 if (!command || !mode)
1193 return NULL;
1194
1195 if (!(cmdW = wstrdupa_utf8(command))) return NULL;
1196 if (!(modeW = msvcrt_wstrdupa(mode)))
1197 {
1198 free(cmdW);
1199 return NULL;
1200 }
1201
1202 ret = _wpopen(cmdW, modeW);
1203
1204 free(cmdW);
1205 free(modeW);
1206 return ret;
1207}
wchar_t * msvcrt_wstrdupa(const char *str)
Definition: data.c:373
FILE *CDECL _wpopen(const wchar_t *command, const wchar_t *mode)
Definition: process.c:1044
GLenum mode
Definition: glext.h:6217
#define debugstr_a
Definition: kernel32.h:31
#define TRACE(s)
Definition: solgame.cpp:4

◆ _spawnl()

intptr_t WINAPIV _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()

intptr_t WINAPIV _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}

◆ _spawnlp()

intptr_t WINAPIV _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()

intptr_t WINAPIV _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()

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}

◆ _spawnve()

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(), and _spawnv().

◆ _spawnvp()

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}

◆ _spawnvpe()

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(), and _spawnvp().

◆ _unloaddll()

int CDECL _unloaddll ( intptr_t  dll)

Definition at line 1331 of file process.c.

1332{
1333 if (FreeLibrary((HMODULE)dll))
1334 return 0;
1335 else
1336 {
1337 int err = GetLastError();
1339 return err;
1340 }
1341}
#define FreeLibrary(x)
Definition: compat.h:748
#define err(...)

◆ _wexecl()

intptr_t WINAPIV _wexecl ( const wchar_t name,
const wchar_t arg0,
  ... 
)

This file has no copyright assigned and is placed in the Public Domain. This file is part of the Wine project.

Definition at line 395 of file process.c.

396{
397 va_list ap;
398 wchar_t *args;
400
401 va_start(ap, arg0);
402 args = msvcrt_valisttos(arg0, ap, ' ');
403 va_end(ap);
404
406
407 free(args);
408 return ret;
409}
static wchar_t * msvcrt_valisttos(const wchar_t *arg0, va_list alist, wchar_t delim)
Definition: process.c:279

◆ _wexecle()

intptr_t WINAPIV _wexecle ( const wchar_t name,
const wchar_t arg0,
  ... 
)

Definition at line 441 of file process.c.

442{
443 va_list ap;
444 wchar_t *args, *envs = NULL;
445 const wchar_t * const *envp;
447
448 va_start(ap, arg0);
449 args = msvcrt_valisttos(arg0, ap, ' ');
450 va_end(ap);
451
452 va_start(ap, arg0);
453 while (va_arg( ap, wchar_t * ) != NULL) /*nothing*/;
454 envp = va_arg( ap, const wchar_t * const * );
455 if (envp) envs = msvcrt_argvtos(envp, 0);
456 va_end(ap);
457
458 ret = msvcrt_spawn(_P_OVERLAY, name, args, envs, 0);
459
460 free(args);
461 free(envs);
462 return ret;
463}
static wchar_t * msvcrt_argvtos(const wchar_t *const *arg, wchar_t delim)
Definition: process.c:191

◆ _wexeclp()

intptr_t WINAPIV _wexeclp ( const wchar_t name,
const wchar_t arg0,
  ... 
)

Definition at line 500 of file process.c.

501{
502 va_list ap;
503 wchar_t *args;
505
506 va_start(ap, arg0);
507 args = msvcrt_valisttos(arg0, ap, ' ');
508 va_end(ap);
509
511
512 free(args);
513 return ret;
514}

◆ _wexeclpe()

intptr_t WINAPIV _wexeclpe ( const wchar_t name,
const wchar_t arg0,
  ... 
)

Definition at line 546 of file process.c.

547{
548 va_list ap;
549 wchar_t *args, *envs = NULL;
550 const wchar_t * const *envp;
552
553 va_start(ap, arg0);
554 args = msvcrt_valisttos(arg0, ap, ' ');
555 va_end(ap);
556
557 va_start(ap, arg0);
558 while (va_arg( ap, wchar_t * ) != NULL) /*nothing*/;
559 envp = va_arg( ap, const wchar_t * const * );
560 if (envp) envs = msvcrt_argvtos(envp, 0);
561 va_end(ap);
562
563 ret = msvcrt_spawn(_P_OVERLAY, name, args, envs, 1);
564
565 free(args);
566 free(envs);
567 return ret;
568}

◆ _wexecv()

intptr_t CDECL _wexecv ( const wchar_t name,
const wchar_t *const argv 
)

Definition at line 605 of file process.c.

606{
607 return _wspawnve(_P_OVERLAY, name, argv, NULL);
608}
intptr_t CDECL _wspawnve(int flags, const wchar_t *name, const wchar_t *const *argv, const wchar_t *const *envv)
Definition: process.c:924

◆ _wexecve()

intptr_t CDECL _wexecve ( const wchar_t name,
const wchar_t *const argv,
const wchar_t *const envv 
)

Definition at line 626 of file process.c.

627{
628 return _wspawnve(_P_OVERLAY, name, argv, envv);
629}

◆ _wexecvp()

intptr_t CDECL _wexecvp ( const wchar_t name,
const wchar_t *const argv 
)

Definition at line 668 of file process.c.

669{
670 return _wexecvpe(name, argv, NULL);
671}
intptr_t CDECL _wexecvpe(const wchar_t *name, const wchar_t *const *argv, const wchar_t *const *envv)
Definition: process.c:647

◆ _wexecvpe()

intptr_t CDECL _wexecvpe ( const wchar_t name,
const wchar_t *const argv,
const wchar_t *const envv 
)

Definition at line 647 of file process.c.

648{
649 return _wspawnvpe(_P_OVERLAY, name, argv, envv);
650}
intptr_t CDECL _wspawnvpe(int flags, const wchar_t *name, const wchar_t *const *argv, const wchar_t *const *envv)
Definition: process.c:991

Referenced by _wexecvp().

◆ _wpopen()

FILE *CDECL _wpopen ( const wchar_t command,
const wchar_t mode 
)

Definition at line 1044 of file process.c.

1045{
1046 wchar_t *comspec, *fullcmd, fullname[MAX_PATH];
1047 int textmode, fds[2], fd_parent, fd_child;
1048 struct popen_handle *container;
1051 const wchar_t *p;
1052 unsigned int len;
1053 STARTUPINFOW si;
1054 FILE *ret;
1055 DWORD i;
1056 BOOL r;
1057
1058 TRACE("(command=%s, mode=%s)\n", debugstr_w(command), debugstr_w(mode));
1059
1060 if (!command || !mode)
1061 return NULL;
1062
1066 for (p = mode; *p; p++)
1067 {
1068 switch (*p)
1069 {
1070 case 'W':
1071 case 'w':
1072 read_pipe = FALSE;
1073 break;
1074 case 'B':
1075 case 'b':
1077 textmode &= ~_O_TEXT;
1078 break;
1079 case 'T':
1080 case 't':
1081 textmode |= _O_TEXT;
1082 textmode &= ~_O_BINARY;
1083 break;
1084 }
1085 }
1086 if (_pipe(fds, 0, textmode) == -1)
1087 return NULL;
1088
1089 if (read_pipe)
1090 {
1091 fd_parent = fds[0];
1092 fd_child = _dup(fds[1]);
1093 _close(fds[1]);
1094 }
1095 else
1096 {
1097 fd_parent = fds[1];
1098 fd_child = _dup(fds[0]);
1099 _close(fds[0]);
1100 }
1101 if (fd_child == -1)
1102 {
1103 _close(fd_parent);
1104 return NULL;
1105 }
1106 ret = _wfdopen(fd_parent, mode);
1107 if (!ret)
1108 {
1109 _close(fd_child);
1110 return NULL;
1111 }
1112
1114 for (i = 0; i < popen_handles_size; i++)
1115 {
1116 if (!popen_handles[i].f)
1117 break;
1118 }
1119 if (i == popen_handles_size)
1120 {
1122 container = realloc(popen_handles, i * sizeof(*container));
1123 if (!container) goto error;
1124
1127 memset(container, 0, (i - popen_handles_size) * sizeof(*container));
1129 }
1130 else container = popen_handles + i;
1131
1132 if (!(comspec = msvcrt_get_comspec())) goto error;
1133 len = wcslen(comspec) + wcslen(command) + 5;
1134
1135 if (!(fullcmd = HeapAlloc(GetProcessHeap(), 0, len * sizeof(wchar_t))))
1136 {
1137 HeapFree(GetProcessHeap(), 0, comspec);
1138 goto error;
1139 }
1140
1141 wcscpy(fullcmd, comspec);
1142 wcscat(fullcmd, L" /c ");
1143 wcscat(fullcmd, command);
1145
1146 memset(&si, 0, sizeof(si));
1147 si.cb = sizeof(si);
1149 if (read_pipe)
1150 {
1152 si.hStdOutput = (HANDLE)_get_osfhandle(fd_child);
1153 }
1154 else
1155 {
1156 si.hStdInput = (HANDLE)_get_osfhandle(fd_child);
1158 }
1160 r = CreateProcessW(fullname, fullcmd, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi);
1161 HeapFree(GetProcessHeap(), 0, comspec);
1162 HeapFree(GetProcessHeap(), 0, fullcmd);
1163 if (!r)
1164 {
1166 goto error;
1167 }
1168 CloseHandle(pi.hThread);
1169 _close(fd_child);
1170 container->proc = pi.hProcess;
1171 container->f = ret;
1173 return ret;
1174
1175error:
1177 _close(fd_child);
1178 fclose(ret);
1179 return NULL;
1180}
#define realloc
Definition: debug_ros.c:6
#define _O_BINARY
Definition: cabinet.h:51
#define _O_NOINHERIT
Definition: cabinet.h:45
#define _O_TEXT
Definition: cabinet.h:50
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessW(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
Definition: proc.c:4600
int CDECL _get_fmode(int *mode)
Definition: data.c:287
int CDECL _close(int fd)
Definition: file.c:1219
int CDECL _pipe(int *pfds, unsigned int psize, int textmode)
Definition: file.c:2323
int CDECL _dup(int od)
Definition: file.c:1317
intptr_t CDECL _get_osfhandle(int fd)
Definition: file.c:2117
textmode
Definition: file.c:95
FILE *CDECL _wfdopen(int fd, const wchar_t *mode)
Definition: file.c:1863
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2983
#define STDOUT_FILENO
Definition: stdio.h:25
#define STDERR_FILENO
Definition: stdio.h:26
#define STDIN_FILENO
Definition: stdio.h:24
static void msvcrt_search_executable(const wchar_t *name, wchar_t *fullname, int use_path)
Definition: process.c:42
static wchar_t * msvcrt_get_comspec(void)
Definition: process.c:346
#define L(x)
Definition: resources.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLfloat GLfloat p
Definition: glext.h:8902
GLenum GLsizei len
Definition: glext.h:6722
#define debugstr_w
Definition: kernel32.h:32
#define error(str)
Definition: mkdosfs.c:1605
const char * fullname
Definition: shader.c:1766
static refpint_t pi[]
Definition: server.c:112
LONG read_pipe(HANDLE hPipe, SOCKET sock)
Definition: pipetunnel.cpp:202
wcscat
wcscpy
#define memset(x, y, z)
Definition: compat.h:39
#define STARTF_USESTDHANDLES
Definition: winbase.h:476

Referenced by _popen().

◆ _wspawnl()

intptr_t WINAPIV _wspawnl ( int  flags,
const wchar_t name,
const wchar_t arg0,
  ... 
)

Definition at line 689 of file process.c.

690{
691 va_list ap;
692 wchar_t *args;
694
695 va_start(ap, arg0);
696 args = msvcrt_valisttos(arg0, ap, ' ');
697 va_end(ap);
698
700
701 free(args);
702 return ret;
703}

◆ _wspawnle()

intptr_t WINAPIV _wspawnle ( int  flags,
const wchar_t name,
const wchar_t arg0,
  ... 
)

Definition at line 735 of file process.c.

736{
737 va_list ap;
738 wchar_t *args, *envs = NULL;
739 const wchar_t * const *envp;
741
742 va_start(ap, arg0);
743 args = msvcrt_valisttos(arg0, ap, ' ');
744 va_end(ap);
745
746 va_start(ap, arg0);
747 while (va_arg( ap, wchar_t * ) != NULL) /*nothing*/;
748 envp = va_arg( ap, const wchar_t * const * );
749 if (envp) envs = msvcrt_argvtos(envp, 0);
750 va_end(ap);
751
752 ret = msvcrt_spawn(flags, name, args, envs, 0);
753
754 free(args);
755 free(envs);
756 return ret;
757}

◆ _wspawnlp()

intptr_t WINAPIV _wspawnlp ( int  flags,
const wchar_t name,
const wchar_t arg0,
  ... 
)

Definition at line 794 of file process.c.

795{
796 va_list ap;
797 wchar_t *args;
799
800 va_start(ap, arg0);
801 args = msvcrt_valisttos(arg0, ap, ' ');
802 va_end(ap);
803
805
806 free(args);
807 return ret;
808}

◆ _wspawnlpe()

intptr_t WINAPIV _wspawnlpe ( int  flags,
const wchar_t name,
const wchar_t arg0,
  ... 
)

Definition at line 840 of file process.c.

841{
842 va_list ap;
843 wchar_t *args, *envs = NULL;
844 const wchar_t * const *envp;
846
847 va_start(ap, arg0);
848 args = msvcrt_valisttos(arg0, ap, ' ');
849 va_end(ap);
850
851 va_start(ap, arg0);
852 while (va_arg( ap, wchar_t * ) != NULL) /*nothing*/;
853 envp = va_arg( ap, const wchar_t * const * );
854 if (envp) envs = msvcrt_argvtos(envp, 0);
855 va_end(ap);
856
857 ret = msvcrt_spawn(flags, name, args, envs, 1);
858
859 free(args);
860 free(envs);
861 return ret;
862}

◆ _wspawnv()

intptr_t CDECL _wspawnv ( int  flags,
const wchar_t name,
const wchar_t *const argv 
)

Definition at line 956 of file process.c.

957{
958 return _wspawnve(flags, name, argv, NULL);
959}

◆ _wspawnve()

intptr_t CDECL _wspawnve ( int  flags,
const wchar_t name,
const wchar_t *const argv,
const wchar_t *const envv 
)

Definition at line 924 of file process.c.

926{
927 wchar_t *args, *envs;
929
930 args = msvcrt_argvtos(argv, ' ');
931 envs = msvcrt_argvtos(envv, 0);
932
933 ret = msvcrt_spawn(flags, name, args, envs, 0);
934
935 free(args);
936 free(envs);
937 return ret;
938}

Referenced by _wexecv(), _wexecve(), and _wspawnv().

◆ _wspawnvp()

intptr_t CDECL _wspawnvp ( int  flags,
const wchar_t name,
const wchar_t *const argv 
)

Definition at line 1023 of file process.c.

1024{
1025 return _wspawnvpe(flags, name, argv, NULL);
1026}

◆ _wspawnvpe()

intptr_t CDECL _wspawnvpe ( int  flags,
const wchar_t name,
const wchar_t *const argv,
const wchar_t *const envv 
)

Definition at line 991 of file process.c.

993{
994 wchar_t *args, *envs;
996
997 args = msvcrt_argvtos(argv, ' ');
998 envs = msvcrt_argvtos(envv, 0);
999
1000 ret = msvcrt_spawn(flags, name, args, envs, 1);
1001
1002 free(args);
1003 free(envs);
1004 return ret;
1005}

Referenced by _wexecvpe(), and _wspawnvp().

◆ _wsystem()

int CDECL _wsystem ( const wchar_t cmd)

Definition at line 1254 of file process.c.

1255{
1256 int res;
1257 wchar_t *comspec, *fullcmd;
1258 unsigned int len;
1259
1260 comspec = msvcrt_get_comspec();
1261
1262 if (cmd == NULL)
1263 {
1264 if (comspec == NULL)
1265 {
1266 *_errno() = ENOENT;
1267 return 0;
1268 }
1269 HeapFree(GetProcessHeap(), 0, comspec);
1270 return 1;
1271 }
1272
1273 if (comspec == NULL)
1274 return -1;
1275
1276 len = wcslen(comspec) + wcslen(cmd) + 5;
1277
1278 if (!(fullcmd = HeapAlloc(GetProcessHeap(), 0, len * sizeof(wchar_t))))
1279 {
1280 HeapFree(GetProcessHeap(), 0, comspec);
1281 return -1;
1282 }
1283 wcscpy(fullcmd, comspec);
1284 wcscat(fullcmd, L" /c ");
1285 wcscat(fullcmd, cmd);
1286
1287 res = msvcrt_spawn(_P_WAIT, comspec, fullcmd, NULL, 1);
1288
1289 HeapFree(GetProcessHeap(), 0, comspec);
1290 HeapFree(GetProcessHeap(), 0, fullcmd);
1291 return res;
1292}
#define ENOENT
Definition: errno.h:25
#define _P_WAIT
Definition: process.h:15
GLuint res
Definition: glext.h:9613
Definition: ftp_var.h:139

Referenced by system().

◆ msvcrt_argvtos()

static wchar_t * msvcrt_argvtos ( const wchar_t *const arg,
wchar_t  delim 
)
static

Definition at line 191 of file process.c.

192{
193 const wchar_t* const* a;
194 int size;
195 wchar_t* p;
196 wchar_t* ret;
197
198 if (!arg)
199 {
200 /* Return NULL for an empty environment list */
201 return NULL;
202 }
203
204 /* get length */
205 a = arg;
206 size = 0;
207 while (*a)
208 {
209 size += wcslen(*a) + 1;
210 a++;
211 }
212
213 ret = malloc((size + 1) * sizeof(wchar_t));
214 if (!ret)
215 return NULL;
216
217 /* fill string */
218 a = arg;
219 p = ret;
220 while (*a)
221 {
222 int len = wcslen(*a);
223 memcpy(p,*a,len * sizeof(wchar_t));
224 p += len;
225 *p++ = delim;
226 a++;
227 }
228 if (delim && p > ret) p[-1] = 0;
229 else *p = 0;
230 return ret;
231}
#define malloc
Definition: debug_ros.c:4
GLsizeiptr size
Definition: glext.h:5919
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define a
Definition: ke_i.h:78
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
void * arg
Definition: msvc.h:10

Referenced by _wexecle(), _wexeclpe(), _wspawnle(), _wspawnlpe(), _wspawnve(), and _wspawnvpe().

◆ msvcrt_argvtos_aw()

static wchar_t * msvcrt_argvtos_aw ( const char *const arg,
BOOL  env 
)
static

Definition at line 236 of file process.c.

237{
238 UINT cp = env ? CP_ACP : get_aw_cp();
239 const char * const *a;
240 unsigned int len;
241 wchar_t *p, *ret;
242
243 if (!arg)
244 {
245 /* Return NULL for an empty environment list */
246 return NULL;
247 }
248
249 /* get length */
250 a = arg;
251 len = 0;
252 while (*a)
253 {
254 len += MultiByteToWideChar(cp, 0, *a, -1, NULL, 0);
255 a++;
256 }
257
258 ret = malloc((len + 1) * sizeof(wchar_t));
259 if (!ret)
260 return NULL;
261
262 /* fill string */
263 a = arg;
264 p = ret;
265 while (*a)
266 {
267 p += MultiByteToWideChar(cp, 0, *a, strlen(*a), p, len - (p - ret));
268 *p++ = env ? 0 : ' ';
269 a++;
270 }
271 if (!env && p > ret) p[-1] = 0;
272 else *p = 0;
273 return ret;
274}
static LPCWSTR LPCWSTR LPCWSTR env
Definition: db.cpp:171
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1592
static UINT get_aw_cp(void)
Definition: msvcrt.h:422
POINT cp
Definition: magnifier.c:59
unsigned int UINT
Definition: ndis.h:50

Referenced by _execle(), _execlpe(), _spawnle(), _spawnlpe(), _spawnve(), and _spawnvpe().

◆ msvcrt_free_popen_data()

void msvcrt_free_popen_data ( void  )

Definition at line 1034 of file process.c.

1035{
1037}

◆ msvcrt_get_comspec()

static wchar_t * msvcrt_get_comspec ( void  )
static

Definition at line 346 of file process.c.

347{
348 wchar_t *ret;
349 unsigned int len;
350
351 if (!(len = GetEnvironmentVariableW(L"COMSPEC", NULL, 0))) len = 4;
352 if ((ret = HeapAlloc(GetProcessHeap(), 0, len * sizeof(wchar_t))))
353 {
354 if (!GetEnvironmentVariableW(L"COMSPEC", ret, len)) wcscpy(ret, L"cmd");
355 }
356 return ret;
357}
#define GetEnvironmentVariableW(x, y, z)
Definition: compat.h:755

Referenced by _wpopen(), and _wsystem().

◆ msvcrt_search_executable()

static void msvcrt_search_executable ( const wchar_t name,
wchar_t fullname,
int  use_path 
)
static

Definition at line 42 of file process.c.

43{
44 static const wchar_t suffix[][5] =
45 {L".com", L".exe", L".bat", L".cmd"};
46
47 wchar_t buffer[MAX_PATH];
48 const wchar_t *env, *p, *end;
49 unsigned int i, name_len, path_len;
50 int extension = 1;
51
52 *fullname = '\0';
53#ifndef __REACTOS__
55#endif
56
57 end = name + MAX_PATH - 1;
58 for(p = name; p < end; p++)
59 if(!*p) break;
60 name_len = p - name;
61
62 /* FIXME extra-long names are silently truncated */
63 memcpy(buffer, name, name_len * sizeof(wchar_t));
64 buffer[name_len] = '\0';
65
66 /* try current dir first */
68 {
70 return;
71 }
72
73 for (p--; p >= name; p--)
74 if (*p == '\\' || *p == '/' || *p == ':' || *p == '.') break;
75
76 /* if there's no extension, try some well-known extensions */
77 if ((p < name || *p != '.') && name_len <= MAX_PATH - 5)
78 {
79 for (i = 0; i < 4; i++)
80 {
81 memcpy(buffer + name_len, suffix[i], 5 * sizeof(wchar_t));
83 {
85 return;
86 }
87 }
88 extension = 0;
89 }
90
91 if (!use_path || !(env = _wgetenv(L"PATH"))) return;
92
93 /* now try search path */
94 do
95 {
96 p = env;
97 while (*p && *p != ';') p++;
98 if (p == env) return;
99
100 path_len = p - env;
101 if (path_len + name_len <= MAX_PATH - 2)
102 {
103 memcpy(buffer, env, path_len * sizeof(wchar_t));
104 if (buffer[path_len] != '/' && buffer[path_len] != '\\')
105 {
106 buffer[path_len++] = '\\';
107 buffer[path_len] = '\0';
108 }
109 else buffer[path_len] = '\0';
110
113 {
115 return;
116 }
117 }
118 /* again, if there's no extension, try some well-known extensions */
119 if (!extension && path_len + name_len <= MAX_PATH - 5)
120 {
121 for (i = 0; i < 4; i++)
122 {
123 memcpy(buffer + path_len + name_len, suffix[i], 5 * sizeof(wchar_t));
125 {
127 return;
128 }
129 }
130 }
131 env = *p ? p + 1 : p;
132 } while(1);
133}
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:652
wchar_t *CDECL _wgetenv(const wchar_t *name)
Definition: environ.c:254
GLuint GLuint end
Definition: gl.h:1545
GLuint buffer
Definition: glext.h:5915
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
static DWORD path_len
Definition: batch.c:31
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23

Referenced by _wpopen(), and msvcrt_spawn().

◆ msvcrt_spawn()

static intptr_t msvcrt_spawn ( int  flags,
const wchar_t exe,
wchar_t cmdline,
wchar_t env,
int  use_path 
)
static

Definition at line 135 of file process.c.

137{
138 STARTUPINFOW si;
140 wchar_t fullname[MAX_PATH];
142
143 TRACE("%x %s %s %s %d\n", flags, debugstr_w(exe), debugstr_w(cmdline), debugstr_w(env), use_path);
144
145 if ((unsigned)flags > _P_DETACH)
146 {
147 *_errno() = EINVAL;
148 return -1;
149 }
150
151 msvcrt_search_executable(exe, fullname, use_path);
152
153 memset(&si, 0, sizeof(si));
154 si.cb = sizeof(si);
158 create_flags, env, NULL, &si, &pi))
159 {
161 free(si.lpReserved2);
162 return -1;
163 }
164
165 free(si.lpReserved2);
166 switch(flags)
167 {
168 case _P_WAIT:
170 GetExitCodeProcess(pi.hProcess,&pi.dwProcessId);
171 CloseHandle(pi.hProcess);
172 CloseHandle(pi.hThread);
173 return pi.dwProcessId;
174 case _P_DETACH:
175 CloseHandle(pi.hProcess);
176 pi.hProcess = 0;
177 /* fall through */
178 case _P_NOWAIT:
179 case _P_NOWAITO:
180 CloseHandle(pi.hThread);
181 return (intptr_t)pi.hProcess;
182 case _P_OVERLAY:
183 _exit(0);
184 }
185 return -1; /* can't reach here */
186}
void CDECL _exit(int exitcode)
Definition: exit.c:187
BOOL msvcrt_create_io_inherit_block(WORD *size, BYTE **block)
Definition: file.c:675
#define EINVAL
Definition: errno.h:44
#define _P_DETACH
Definition: process.h:19
#define _P_NOWAIT
Definition: process.h:16
#define _P_NOWAITO
Definition: process.h:18
DWORD create_flags
Definition: sec_mgr.c:1589
TCHAR * cmdline
Definition: stretchblt.cpp:32
#define CREATE_UNICODE_ENVIRONMENT
Definition: winbase.h:190
#define DETACHED_PROCESS
Definition: winbase.h:183

Referenced by _execl(), _execle(), _execlp(), _execlpe(), _spawnl(), _spawnle(), _spawnlp(), _spawnlpe(), _spawnve(), _spawnvpe(), _wexecl(), _wexecle(), _wexeclp(), _wexeclpe(), _wspawnl(), _wspawnle(), _wspawnlp(), _wspawnlpe(), _wspawnve(), _wspawnvpe(), and _wsystem().

◆ msvcrt_valisttos()

static wchar_t * msvcrt_valisttos ( const wchar_t arg0,
va_list  alist,
wchar_t  delim 
)
static

Definition at line 279 of file process.c.

280{
281 unsigned int size = 0, pos = 0;
282 const wchar_t *arg;
283 wchar_t *new, *ret = NULL;
284
285 for (arg = arg0; arg; arg = va_arg( alist, wchar_t * ))
286 {
287 unsigned int len = wcslen( arg ) + 1;
288 if (pos + len >= size)
289 {
290 size = max( 256, size * 2 );
291 size = max( size, pos + len + 1 );
292 if (!(new = realloc( ret, size * sizeof(wchar_t) )))
293 {
294 free( ret );
295 return NULL;
296 }
297 ret = new;
298 }
299 wcscpy( ret + pos, arg );
300 pos += len;
301 ret[pos - 1] = delim;
302 }
303 if (pos)
304 {
305 if (delim) ret[pos - 1] = 0;
306 else ret[pos] = 0;
307 }
308 return ret;
309}
#define max(a, b)
Definition: svc.c:63

Referenced by _wexecl(), _wexecle(), _wexeclp(), _wexeclpe(), _wspawnl(), _wspawnle(), _wspawnlp(), and _wspawnlpe().

◆ msvcrt_valisttos_aw()

static wchar_t * msvcrt_valisttos_aw ( const char arg0,
va_list  alist,
wchar_t  delim 
)
static

Definition at line 314 of file process.c.

315{
316 unsigned int size = 0, pos = 0;
317 const char *arg;
318 wchar_t *new, *ret = NULL;
319
320 for (arg = arg0; arg; arg = va_arg( alist, char * ))
321 {
322 unsigned int len = convert_acp_utf8_to_wcs( arg, NULL, 0 );
323 if (pos + len >= size)
324 {
325 size = max( 256, size * 2 );
326 size = max( size, pos + len + 1 );
327 if (!(new = realloc( ret, size * sizeof(wchar_t) )))
328 {
329 free( ret );
330 return NULL;
331 }
332 ret = new;
333 }
335 ret[pos - 1] = delim;
336 }
337 if (pos)
338 {
339 if (delim) ret[pos - 1] = 0;
340 else ret[pos] = 0;
341 }
342 return ret;
343}
static int convert_acp_utf8_to_wcs(const char *str, wchar_t *wstr, int len)
Definition: msvcrt.h:430

Referenced by _execl(), _execle(), _execlp(), _execlpe(), _spawnl(), _spawnle(), _spawnlp(), and _spawnlpe().

◆ system()

int CDECL system ( const char cmd)

Definition at line 1297 of file process.c.

1298{
1299 int res = -1;
1300 wchar_t *cmdW;
1301
1302 if (cmd == NULL)
1303 return _wsystem(NULL);
1304
1305 if ((cmdW = wstrdupa_utf8(cmd)))
1306 {
1307 res = _wsystem(cmdW);
1308 free(cmdW);
1309 }
1310 return res;
1311}
int CDECL _wsystem(const wchar_t *cmd)
Definition: process.c:1254

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( msvcrt  )

Variable Documentation

◆ popen_handles

struct popen_handle * popen_handles
static

◆ popen_handles_size

DWORD popen_handles_size
static

Definition at line 1032 of file process.c.

Referenced by _pclose(), and _wpopen().