Cygwin: mmap: allow remapping part of an existing anonymous mapping
[newlib-cygwin.git] / newlib / libc / reent / execr.c
blob541fb862428f7bd1ad6ba78065404b2d5609317d
1 /* Reentrant versions of execution system calls. These
2 implementations just call the usual system calls. */
4 #include <reent.h>
5 #include <unistd.h>
6 #include <sys/wait.h>
7 #include <_syslist.h>
9 /* Some targets provides their own versions of these functions. Those
10 targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */
12 #ifdef _REENT_ONLY
13 #ifndef REENTRANT_SYSCALLS_PROVIDED
14 #define REENTRANT_SYSCALLS_PROVIDED
15 #endif
16 #endif
18 /* If NO_EXEC is defined, we don't need these functions. */
20 #if defined (REENTRANT_SYSCALLS_PROVIDED) || defined (NO_EXEC)
22 int _dummy_exec_syscalls = 1;
24 #else
26 /* We use the errno variable used by the system dependent layer. */
27 #undef errno
28 extern int errno;
31 FUNCTION
32 <<_execve_r>>---Reentrant version of execve
33 INDEX
34 _execve_r
36 SYNOPSIS
37 #include <reent.h>
38 int _execve_r(struct _reent *<[ptr]>, const char *<[name]>,
39 char *const <[argv]>[], char *const <[env]>[]);
41 DESCRIPTION
42 This is a reentrant version of <<execve>>. It
43 takes a pointer to the global data block, which holds
44 <<errno>>.
47 int
48 _execve_r (struct _reent *ptr,
49 const char *name,
50 char *const argv[],
51 char *const env[])
53 int ret;
55 errno = 0;
56 if ((ret = _execve (name, argv, env)) == -1 && errno != 0)
57 _REENT_ERRNO(ptr) = errno;
58 return ret;
63 NEWPAGE
64 FUNCTION
65 <<_fork_r>>---Reentrant version of fork
67 INDEX
68 _fork_r
70 SYNOPSIS
71 #include <reent.h>
72 int _fork_r(struct _reent *<[ptr]>);
74 DESCRIPTION
75 This is a reentrant version of <<fork>>. It
76 takes a pointer to the global data block, which holds
77 <<errno>>.
80 #ifndef NO_FORK
82 int
83 _fork_r (struct _reent *ptr)
85 int ret;
87 errno = 0;
88 if ((ret = _fork ()) == -1 && errno != 0)
89 _REENT_ERRNO(ptr) = errno;
90 return ret;
93 #endif
96 NEWPAGE
97 FUNCTION
98 <<_wait_r>>---Reentrant version of wait
100 INDEX
101 _wait_r
103 SYNOPSIS
104 #include <reent.h>
105 int _wait_r(struct _reent *<[ptr]>, int *<[status]>);
107 DESCRIPTION
108 This is a reentrant version of <<wait>>. It
109 takes a pointer to the global data block, which holds
110 <<errno>>.
114 _wait_r (struct _reent *ptr,
115 int *status)
117 int ret;
119 errno = 0;
120 if ((ret = _wait (status)) == -1 && errno != 0)
121 _REENT_ERRNO(ptr) = errno;
122 return ret;
125 #endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */