Cygwin: add newgrp release notes
[newlib-cygwin.git] / winsup / cygwin / exec.cc
blob2f4041329a6534ed06de230661fea2c898ed3139
1 /* exec.cc: exec system call support.
3 This file is part of Cygwin.
5 This software is a copyrighted work licensed under the terms of the
6 Cygwin license. Please consult the file "CYGWIN_LICENSE" for
7 details. */
9 #include "winsup.h"
10 #include <process.h>
11 #include "cygerrno.h"
12 #include "path.h"
13 #include "environ.h"
14 #include "sync.h"
15 #include "fhandler.h"
16 #include "dtable.h"
17 #include "pinfo.h"
18 #include "cygheap.h"
19 #include "winf.h"
21 extern "C" int
22 execl (const char *path, const char *arg0, ...)
24 int i;
25 va_list args;
26 const char *argv[1024];
28 va_start (args, arg0);
29 argv[0] = arg0;
30 i = 1;
32 argv[i] = va_arg (args, const char *);
33 while (argv[i++] != NULL);
34 va_end (args);
35 return spawnve (_P_OVERLAY, path, (char * const *) argv, environ);
38 extern "C" int
39 execle (const char *path, const char *arg0, ...)
41 int i;
42 va_list args;
43 const char *argv[1024];
44 const char * const *envp;
46 va_start (args, arg0);
47 argv[0] = arg0;
48 i = 1;
50 argv[i] = va_arg (args, const char *);
51 while (argv[i++] != NULL);
52 envp = va_arg (args, const char * const *);
53 va_end (args);
54 return spawnve (_P_OVERLAY, path, (char * const *) argv, envp);
57 extern "C" int
58 execlp (const char *file, const char *arg0, ...)
60 int i;
61 va_list args;
62 const char *argv[1024];
63 path_conv buf;
65 va_start (args, arg0);
66 argv[0] = arg0;
67 i = 1;
69 argv[i] = va_arg (args, const char *);
70 while (argv[i++] != NULL);
71 va_end (args);
72 return spawnve (_P_OVERLAY | _P_PATH_TYPE_EXEC,
73 find_exec (file, buf, "PATH", FE_NNF) ?: "",
74 (char * const *) argv, environ);
77 extern "C" int
78 execv (const char *path, char * const *argv)
80 return spawnve (_P_OVERLAY, path, argv, environ);
83 extern "C" int
84 execve (const char *path, char *const argv[], char *const envp[])
86 return spawnve (_P_OVERLAY, path, argv, envp);
88 EXPORT_ALIAS (execve, _execve) /* For newlib */
90 extern "C" int
91 execvp (const char *file, char * const *argv)
93 path_conv buf;
95 return spawnve (_P_OVERLAY | _P_PATH_TYPE_EXEC,
96 find_exec (file, buf, "PATH", FE_NNF) ?: "",
97 argv, environ);
100 extern "C" int
101 execvpe (const char *file, char * const *argv, char *const *envp)
103 path_conv buf;
105 return spawnve (_P_OVERLAY | _P_PATH_TYPE_EXEC,
106 find_exec (file, buf, "PATH", FE_NNF) ?: "",
107 argv, envp);
110 extern "C" int
111 fexecve (int fd, char * const *argv, char *const *envp)
113 cygheap_fdget cfd (fd);
114 if (cfd < 0)
116 syscall_printf ("-1 = fexecve (%d, %p, %p)", fd, argv, envp);
117 return -1;
120 return spawnve (_P_OVERLAY, cfd->pc.get_win32 (), argv, envp);
123 extern "C" pid_t
124 sexecve_is_bad ()
126 set_errno (ENOSYS);
127 return 0;