author | chegar |
Thu, 17 Oct 2019 20:54:25 +0100 | |
branch | datagramsocketimpl-branch |
changeset 58679 | 9c3209ff7550 |
parent 58678 | 9cf78a70fa4f |
parent 55753 | b9798272720b |
permissions | -rw-r--r-- |
19399
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
1 |
/* |
55753
b9798272720b
8227737: avoid implicit-function-declaration on AIX
mbaesken
parents:
55240
diff
changeset
|
2 |
* Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved. |
19399
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
4 |
* |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
10 |
* |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
15 |
* accompanied this code). |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
16 |
* |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
20 |
* |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
23 |
* questions. |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
24 |
*/ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
25 |
|
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
26 |
#include <dirent.h> |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
27 |
#include <errno.h> |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
28 |
#include <fcntl.h> |
55753
b9798272720b
8227737: avoid implicit-function-declaration on AIX
mbaesken
parents:
55240
diff
changeset
|
29 |
#include <stdio.h> |
19399
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
30 |
#include <stdlib.h> |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
31 |
#include <string.h> |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
32 |
#include <unistd.h> |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
33 |
#include <limits.h> |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
34 |
|
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
35 |
#include "childproc.h" |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
36 |
|
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
37 |
|
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
38 |
ssize_t |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
39 |
restartableWrite(int fd, const void *buf, size_t count) |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
40 |
{ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
41 |
ssize_t result; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
42 |
RESTARTABLE(write(fd, buf, count), result); |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
43 |
return result; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
44 |
} |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
45 |
|
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
46 |
int |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
47 |
restartableDup2(int fd_from, int fd_to) |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
48 |
{ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
49 |
int err; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
50 |
RESTARTABLE(dup2(fd_from, fd_to), err); |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
51 |
return err; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
52 |
} |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
53 |
|
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
54 |
int |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
55 |
closeSafely(int fd) |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
56 |
{ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
57 |
return (fd == -1) ? 0 : close(fd); |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
58 |
} |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
59 |
|
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
60 |
int |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
61 |
isAsciiDigit(char c) |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
62 |
{ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
63 |
return c >= '0' && c <= '9'; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
64 |
} |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
65 |
|
42944 | 66 |
#if defined(_AIX) |
67 |
/* AIX does not understand '/proc/self' - it requires the real process ID */ |
|
68 |
#define FD_DIR aix_fd_dir |
|
69 |
#define DIR DIR64 |
|
51597
4c78f4fd8370
8207744: Clean up inconsistent use of opendir/closedir versus opendir64/closedir64
bpb
parents:
47216
diff
changeset
|
70 |
#define dirent dirent64 |
42944 | 71 |
#define opendir opendir64 |
51597
4c78f4fd8370
8207744: Clean up inconsistent use of opendir/closedir versus opendir64/closedir64
bpb
parents:
47216
diff
changeset
|
72 |
#define readdir readdir64 |
42944 | 73 |
#define closedir closedir64 |
74 |
#elif defined(_ALLBSD_SOURCE) |
|
75 |
#define FD_DIR "/dev/fd" |
|
19399
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
76 |
#else |
42944 | 77 |
#define FD_DIR "/proc/self/fd" |
19399
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
78 |
#endif |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
79 |
|
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
80 |
int |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
81 |
closeDescriptors(void) |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
82 |
{ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
83 |
DIR *dp; |
51597
4c78f4fd8370
8207744: Clean up inconsistent use of opendir/closedir versus opendir64/closedir64
bpb
parents:
47216
diff
changeset
|
84 |
struct dirent *dirp; |
19399
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
85 |
int from_fd = FAIL_FILENO + 1; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
86 |
|
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
87 |
/* We're trying to close all file descriptors, but opendir() might |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
88 |
* itself be implemented using a file descriptor, and we certainly |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
89 |
* don't want to close that while it's in use. We assume that if |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
90 |
* opendir() is implemented using a file descriptor, then it uses |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
91 |
* the lowest numbered file descriptor, just like open(). So we |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
92 |
* close a couple explicitly. */ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
93 |
|
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
94 |
close(from_fd); /* for possible use by opendir() */ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
95 |
close(from_fd + 1); /* another one for good luck */ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
96 |
|
22597
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
19399
diff
changeset
|
97 |
#if defined(_AIX) |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
19399
diff
changeset
|
98 |
/* AIX does not understand '/proc/self' - it requires the real process ID */ |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
19399
diff
changeset
|
99 |
char aix_fd_dir[32]; /* the pid has at most 19 digits */ |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
19399
diff
changeset
|
100 |
snprintf(aix_fd_dir, 32, "/proc/%d/fd", getpid()); |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
19399
diff
changeset
|
101 |
#endif |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
19399
diff
changeset
|
102 |
|
19399
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
103 |
if ((dp = opendir(FD_DIR)) == NULL) |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
104 |
return 0; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
105 |
|
51597
4c78f4fd8370
8207744: Clean up inconsistent use of opendir/closedir versus opendir64/closedir64
bpb
parents:
47216
diff
changeset
|
106 |
while ((dirp = readdir(dp)) != NULL) { |
19399
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
107 |
int fd; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
108 |
if (isAsciiDigit(dirp->d_name[0]) && |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
109 |
(fd = strtol(dirp->d_name, NULL, 10)) >= from_fd + 2) |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
110 |
close(fd); |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
111 |
} |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
112 |
|
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
113 |
closedir(dp); |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
114 |
|
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
115 |
return 1; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
116 |
} |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
117 |
|
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
118 |
int |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
119 |
moveDescriptor(int fd_from, int fd_to) |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
120 |
{ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
121 |
if (fd_from != fd_to) { |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
122 |
if ((restartableDup2(fd_from, fd_to) == -1) || |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
123 |
(close(fd_from) == -1)) |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
124 |
return -1; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
125 |
} |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
126 |
return 0; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
127 |
} |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
128 |
|
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
129 |
int |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
130 |
magicNumber() { |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
131 |
return 43110; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
132 |
} |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
133 |
|
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
134 |
/* |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
135 |
* Reads nbyte bytes from file descriptor fd into buf, |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
136 |
* The read operation is retried in case of EINTR or partial reads. |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
137 |
* |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
138 |
* Returns number of bytes read (normally nbyte, but may be less in |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
139 |
* case of EOF). In case of read errors, returns -1 and sets errno. |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
140 |
*/ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
141 |
ssize_t |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
142 |
readFully(int fd, void *buf, size_t nbyte) |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
143 |
{ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
144 |
ssize_t remaining = nbyte; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
145 |
for (;;) { |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
146 |
ssize_t n = read(fd, buf, remaining); |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
147 |
if (n == 0) { |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
148 |
return nbyte - remaining; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
149 |
} else if (n > 0) { |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
150 |
remaining -= n; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
151 |
if (remaining <= 0) |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
152 |
return nbyte; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
153 |
/* We were interrupted in the middle of reading the bytes. |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
154 |
* Unlikely, but possible. */ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
155 |
buf = (void *) (((char *)buf) + n); |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
156 |
} else if (errno == EINTR) { |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
157 |
/* Strange signals like SIGJVM1 are possible at any time. |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
158 |
* See http://www.dreamsongs.com/WorseIsBetter.html */ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
159 |
} else { |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
160 |
return -1; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
161 |
} |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
162 |
} |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
163 |
} |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
164 |
|
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
165 |
void |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
166 |
initVectorFromBlock(const char**vector, const char* block, int count) |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
167 |
{ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
168 |
int i; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
169 |
const char *p; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
170 |
for (i = 0, p = block; i < count; i++) { |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
171 |
/* Invariant: p always points to the start of a C string. */ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
172 |
vector[i] = p; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
173 |
while (*(p++)); |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
174 |
} |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
175 |
vector[count] = NULL; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
176 |
} |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
177 |
|
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
178 |
/** |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
179 |
* Exec FILE as a traditional Bourne shell script (i.e. one without #!). |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
180 |
* If we could do it over again, we would probably not support such an ancient |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
181 |
* misfeature, but compatibility wins over sanity. The original support for |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
182 |
* this was imported accidentally from execvp(). |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
183 |
*/ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
184 |
void |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
185 |
execve_as_traditional_shell_script(const char *file, |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
186 |
const char *argv[], |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
187 |
const char *const envp[]) |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
188 |
{ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
189 |
/* Use the extra word of space provided for us in argv by caller. */ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
190 |
const char *argv0 = argv[0]; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
191 |
const char *const *end = argv; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
192 |
while (*end != NULL) |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
193 |
++end; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
194 |
memmove(argv+2, argv+1, (end-argv) * sizeof(*end)); |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
195 |
argv[0] = "/bin/sh"; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
196 |
argv[1] = file; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
197 |
execve(argv[0], (char **) argv, (char **) envp); |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
198 |
/* Can't even exec /bin/sh? Big trouble, but let's soldier on... */ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
199 |
memmove(argv+1, argv+2, (end-argv) * sizeof(*end)); |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
200 |
argv[0] = argv0; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
201 |
} |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
202 |
|
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
203 |
/** |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
204 |
* Like execve(2), except that in case of ENOEXEC, FILE is assumed to |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
205 |
* be a shell script and the system default shell is invoked to run it. |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
206 |
*/ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
207 |
void |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
208 |
execve_with_shell_fallback(int mode, const char *file, |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
209 |
const char *argv[], |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
210 |
const char *const envp[]) |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
211 |
{ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
212 |
if (mode == MODE_CLONE || mode == MODE_VFORK) { |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
213 |
/* shared address space; be very careful. */ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
214 |
execve(file, (char **) argv, (char **) envp); |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
215 |
if (errno == ENOEXEC) |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
216 |
execve_as_traditional_shell_script(file, argv, envp); |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
217 |
} else { |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
218 |
/* unshared address space; we can mutate environ. */ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
219 |
environ = (char **) envp; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
220 |
execvp(file, (char **) argv); |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
221 |
} |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
222 |
} |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
223 |
|
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
224 |
/** |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
225 |
* 'execvpe' should have been included in the Unix standards, |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
226 |
* and is a GNU extension in glibc 2.10. |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
227 |
* |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
228 |
* JDK_execvpe is identical to execvp, except that the child environment is |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
229 |
* specified via the 3rd argument instead of being inherited from environ. |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
230 |
*/ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
231 |
void |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
232 |
JDK_execvpe(int mode, const char *file, |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
233 |
const char *argv[], |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
234 |
const char *const envp[]) |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
235 |
{ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
236 |
if (envp == NULL || (char **) envp == environ) { |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
237 |
execvp(file, (char **) argv); |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
238 |
return; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
239 |
} |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
240 |
|
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
241 |
if (*file == '\0') { |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
242 |
errno = ENOENT; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
243 |
return; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
244 |
} |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
245 |
|
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
246 |
if (strchr(file, '/') != NULL) { |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
247 |
execve_with_shell_fallback(mode, file, argv, envp); |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
248 |
} else { |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
249 |
/* We must search PATH (parent's, not child's) */ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
250 |
char expanded_file[PATH_MAX]; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
251 |
int filelen = strlen(file); |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
252 |
int sticky_errno = 0; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
253 |
const char * const * dirs; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
254 |
for (dirs = parentPathv; *dirs; dirs++) { |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
255 |
const char * dir = *dirs; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
256 |
int dirlen = strlen(dir); |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
257 |
if (filelen + dirlen + 2 >= PATH_MAX) { |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
258 |
errno = ENAMETOOLONG; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
259 |
continue; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
260 |
} |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
261 |
memcpy(expanded_file, dir, dirlen); |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
262 |
if (expanded_file[dirlen - 1] != '/') |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
263 |
expanded_file[dirlen++] = '/'; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
264 |
memcpy(expanded_file + dirlen, file, filelen); |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
265 |
expanded_file[dirlen + filelen] = '\0'; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
266 |
execve_with_shell_fallback(mode, expanded_file, argv, envp); |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
267 |
/* There are 3 responses to various classes of errno: |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
268 |
* return immediately, continue (especially for ENOENT), |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
269 |
* or continue with "sticky" errno. |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
270 |
* |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
271 |
* From exec(3): |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
272 |
* |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
273 |
* If permission is denied for a file (the attempted |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
274 |
* execve returned EACCES), these functions will continue |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
275 |
* searching the rest of the search path. If no other |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
276 |
* file is found, however, they will return with the |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
277 |
* global variable errno set to EACCES. |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
278 |
*/ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
279 |
switch (errno) { |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
280 |
case EACCES: |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
281 |
sticky_errno = errno; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
282 |
/* FALLTHRU */ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
283 |
case ENOENT: |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
284 |
case ENOTDIR: |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
285 |
#ifdef ELOOP |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
286 |
case ELOOP: |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
287 |
#endif |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
288 |
#ifdef ESTALE |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
289 |
case ESTALE: |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
290 |
#endif |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
291 |
#ifdef ENODEV |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
292 |
case ENODEV: |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
293 |
#endif |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
294 |
#ifdef ETIMEDOUT |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
295 |
case ETIMEDOUT: |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
296 |
#endif |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
297 |
break; /* Try other directories in PATH */ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
298 |
default: |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
299 |
return; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
300 |
} |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
301 |
} |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
302 |
if (sticky_errno != 0) |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
303 |
errno = sticky_errno; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
304 |
} |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
305 |
} |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
306 |
|
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
307 |
/** |
29724
638809ff54f3
7021006: (process) Remove disabled clone-exec feature
rriggs
parents:
25859
diff
changeset
|
308 |
* Child process after a successful fork(). |
19399
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
309 |
* This function must not return, and must be prepared for either all |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
310 |
* of its address space to be shared with its parent, or to be a copy. |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
311 |
* It must not modify global variables such as "environ". |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
312 |
*/ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
313 |
int |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
314 |
childProcess(void *arg) |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
315 |
{ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
316 |
const ChildStuff* p = (const ChildStuff*) arg; |
55218
412ce076c0dc
8224181: On child process spawn, child may write to random file descriptor instead of the fail pipe
stuefe
parents:
51597
diff
changeset
|
317 |
int fail_pipe_fd = p->fail[1]; |
19399
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
318 |
|
55240
57b93b113ec0
8223777: In posix_spawn mode, failing to exec() jspawnhelper does not result in an error
stuefe
parents:
55218
diff
changeset
|
319 |
if (p->sendAlivePing) { |
57b93b113ec0
8223777: In posix_spawn mode, failing to exec() jspawnhelper does not result in an error
stuefe
parents:
55218
diff
changeset
|
320 |
/* Child shall signal aliveness to parent at the very first |
57b93b113ec0
8223777: In posix_spawn mode, failing to exec() jspawnhelper does not result in an error
stuefe
parents:
55218
diff
changeset
|
321 |
* moment. */ |
57b93b113ec0
8223777: In posix_spawn mode, failing to exec() jspawnhelper does not result in an error
stuefe
parents:
55218
diff
changeset
|
322 |
int code = CHILD_IS_ALIVE; |
57b93b113ec0
8223777: In posix_spawn mode, failing to exec() jspawnhelper does not result in an error
stuefe
parents:
55218
diff
changeset
|
323 |
restartableWrite(fail_pipe_fd, &code, sizeof(code)); |
57b93b113ec0
8223777: In posix_spawn mode, failing to exec() jspawnhelper does not result in an error
stuefe
parents:
55218
diff
changeset
|
324 |
} |
57b93b113ec0
8223777: In posix_spawn mode, failing to exec() jspawnhelper does not result in an error
stuefe
parents:
55218
diff
changeset
|
325 |
|
19399
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
326 |
/* Close the parent sides of the pipes. |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
327 |
Closing pipe fds here is redundant, since closeDescriptors() |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
328 |
would do it anyways, but a little paranoia is a good thing. */ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
329 |
if ((closeSafely(p->in[1]) == -1) || |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
330 |
(closeSafely(p->out[0]) == -1) || |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
331 |
(closeSafely(p->err[0]) == -1) || |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
332 |
(closeSafely(p->childenv[0]) == -1) || |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
333 |
(closeSafely(p->childenv[1]) == -1) || |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
334 |
(closeSafely(p->fail[0]) == -1)) |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
335 |
goto WhyCantJohnnyExec; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
336 |
|
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
337 |
/* Give the child sides of the pipes the right fileno's. */ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
338 |
/* Note: it is possible for in[0] == 0 */ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
339 |
if ((moveDescriptor(p->in[0] != -1 ? p->in[0] : p->fds[0], |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
340 |
STDIN_FILENO) == -1) || |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
341 |
(moveDescriptor(p->out[1]!= -1 ? p->out[1] : p->fds[1], |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
342 |
STDOUT_FILENO) == -1)) |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
343 |
goto WhyCantJohnnyExec; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
344 |
|
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
345 |
if (p->redirectErrorStream) { |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
346 |
if ((closeSafely(p->err[1]) == -1) || |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
347 |
(restartableDup2(STDOUT_FILENO, STDERR_FILENO) == -1)) |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
348 |
goto WhyCantJohnnyExec; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
349 |
} else { |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
350 |
if (moveDescriptor(p->err[1] != -1 ? p->err[1] : p->fds[2], |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
351 |
STDERR_FILENO) == -1) |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
352 |
goto WhyCantJohnnyExec; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
353 |
} |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
354 |
|
55218
412ce076c0dc
8224181: On child process spawn, child may write to random file descriptor instead of the fail pipe
stuefe
parents:
51597
diff
changeset
|
355 |
if (moveDescriptor(fail_pipe_fd, FAIL_FILENO) == -1) |
19399
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
356 |
goto WhyCantJohnnyExec; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
357 |
|
55218
412ce076c0dc
8224181: On child process spawn, child may write to random file descriptor instead of the fail pipe
stuefe
parents:
51597
diff
changeset
|
358 |
/* We moved the fail pipe fd */ |
412ce076c0dc
8224181: On child process spawn, child may write to random file descriptor instead of the fail pipe
stuefe
parents:
51597
diff
changeset
|
359 |
fail_pipe_fd = FAIL_FILENO; |
412ce076c0dc
8224181: On child process spawn, child may write to random file descriptor instead of the fail pipe
stuefe
parents:
51597
diff
changeset
|
360 |
|
19399
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
361 |
/* close everything */ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
362 |
if (closeDescriptors() == 0) { /* failed, close the old way */ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
363 |
int max_fd = (int)sysconf(_SC_OPEN_MAX); |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
364 |
int fd; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
365 |
for (fd = FAIL_FILENO + 1; fd < max_fd; fd++) |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
366 |
if (close(fd) == -1 && errno != EBADF) |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
367 |
goto WhyCantJohnnyExec; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
368 |
} |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
369 |
|
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
370 |
/* change to the new working directory */ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
371 |
if (p->pdir != NULL && chdir(p->pdir) < 0) |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
372 |
goto WhyCantJohnnyExec; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
373 |
|
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
374 |
if (fcntl(FAIL_FILENO, F_SETFD, FD_CLOEXEC) == -1) |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
375 |
goto WhyCantJohnnyExec; |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
376 |
|
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
377 |
JDK_execvpe(p->mode, p->argv[0], p->argv, p->envv); |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
378 |
|
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
379 |
WhyCantJohnnyExec: |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
380 |
/* We used to go to an awful lot of trouble to predict whether the |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
381 |
* child would fail, but there is no reliable way to predict the |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
382 |
* success of an operation without *trying* it, and there's no way |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
383 |
* to try a chdir or exec in the parent. Instead, all we need is a |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
384 |
* way to communicate any failure back to the parent. Easy; we just |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
385 |
* send the errno back to the parent over a pipe in case of failure. |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
386 |
* The tricky thing is, how do we communicate the *success* of exec? |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
387 |
* We use FD_CLOEXEC together with the fact that a read() on a pipe |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
388 |
* yields EOF when the write ends (we have two of them!) are closed. |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
389 |
*/ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
390 |
{ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
391 |
int errnum = errno; |
55218
412ce076c0dc
8224181: On child process spawn, child may write to random file descriptor instead of the fail pipe
stuefe
parents:
51597
diff
changeset
|
392 |
restartableWrite(fail_pipe_fd, &errnum, sizeof(errnum)); |
19399
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
393 |
} |
55218
412ce076c0dc
8224181: On child process spawn, child may write to random file descriptor instead of the fail pipe
stuefe
parents:
51597
diff
changeset
|
394 |
close(fail_pipe_fd); |
19399
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
395 |
_exit(-1); |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
396 |
return 0; /* Suppress warning "no return value from function" */ |
e2e5122cd62e
5049299: (process) Use posix_spawn, not fork, on S10 to avoid swap exhaustion
robm
parents:
diff
changeset
|
397 |
} |