1 /* source: xio-progcall.c */
2 /* Copyright Gerhard Rieger */
3 /* Published under the GNU General Public License V.2, see file COPYING */
5 /* this file contains common code dealing with program calls (exec, system) */
7 #include "xiosysincludes.h"
10 #include "xio-process.h"
11 #include "xio-progcall.h"
13 #include "xio-socket.h"
16 /* these options are used by address pty too */
18 const struct optdesc opt_openpty
= { "openpty", NULL
, OPT_OPENPTY
, GROUP_PTY
, PH_BIGEN
, TYPE_BOOL
, OFUNC_SPEC
};
19 #endif /* HAVE_OPENPTY */
20 #if HAVE_DEV_PTMX || HAVE_DEV_PTC
21 const struct optdesc opt_ptmx
= { "ptmx", NULL
, OPT_PTMX
, GROUP_PTY
, PH_BIGEN
, TYPE_BOOL
, OFUNC_SPEC
};
24 #if WITH_EXEC || WITH_SYSTEM
26 #define MAXPTYNAMELEN 64
28 const struct optdesc opt_fdin
= { "fdin", NULL
, OPT_FDIN
, GROUP_FORK
, PH_PASTBIGEN
, TYPE_USHORT
, OFUNC_SPEC
};
29 const struct optdesc opt_fdout
= { "fdout", NULL
, OPT_FDOUT
, GROUP_FORK
, PH_PASTBIGEN
, TYPE_USHORT
, OFUNC_SPEC
};
30 const struct optdesc opt_path
= { "path", NULL
, OPT_PATH
, GROUP_EXEC
, PH_PREEXEC
, TYPE_STRING
, OFUNC_SPEC
};
31 const struct optdesc opt_pipes
= { "pipes", NULL
, OPT_PIPES
, GROUP_FORK
, PH_BIGEN
, TYPE_BOOL
, OFUNC_SPEC
};
33 const struct optdesc opt_pty
= { "pty", NULL
, OPT_PTY
, GROUP_FORK
, PH_BIGEN
, TYPE_BOOL
, OFUNC_SPEC
};
35 const struct optdesc opt_stderr
= { "stderr", NULL
, OPT_STDERR
, GROUP_FORK
, PH_PASTFORK
, TYPE_BOOL
, OFUNC_SPEC
};
36 const struct optdesc opt_nofork
= { "nofork", NULL
, OPT_NOFORK
, GROUP_FORK
, PH_BIGEN
, TYPE_BOOL
, OFUNC_SPEC
};
37 const struct optdesc opt_sighup
= { "sighup", NULL
, OPT_SIGHUP
, GROUP_PARENT
, PH_LATE
, TYPE_CONST
, OFUNC_SIGNAL
, SIGHUP
};
38 const struct optdesc opt_sigint
= { "sigint", NULL
, OPT_SIGINT
, GROUP_PARENT
, PH_LATE
, TYPE_CONST
, OFUNC_SIGNAL
, SIGINT
};
39 const struct optdesc opt_sigquit
= { "sigquit", NULL
, OPT_SIGQUIT
, GROUP_PARENT
, PH_LATE
, TYPE_CONST
, OFUNC_SIGNAL
, SIGQUIT
};
42 /* fork for exec/system, but return before exec'ing.
43 return=0: is child process
44 return>0: is parent process
45 return<0: error occurred, assume parent process and no child exists !!!
47 int _xioopen_foxec(int xioflags
, /* XIO_RDONLY etc. */
50 struct opt
**copts
, /* in: opts; out: opts for child */
51 int *duptostderr
/* out: redirect stderr to output fd */
53 struct opt
*popts
; /* parent process options */
55 int d
, sv
[2], rdpip
[2], wrpip
[2];
56 int rw
= (xioflags
& XIO_ACCMODE
);
57 bool usepipes
= false;
59 int ptyfd
= -1, ttyfd
= -1;
60 bool usebestpty
= false; /* use the best available way to open pty */
61 #if defined(HAVE_DEV_PTMX) || defined(HAVE_DEV_PTC)
62 bool useptmx
= false; /* use /dev/ptmx or equivalent */
65 bool useopenpty
= false; /* try only openpty */
66 #endif /* HAVE_OPENPTY */
67 bool usepty
= false; /* any of the pty options is selected */
68 char ptyname
[MAXPTYNAMELEN
];
70 pid_t pid
= 0; /* mostly int */
71 short fdi
= 0, fdo
= 1;
73 bool withstderr
= false;
77 popts
= moveopts(*copts
, GROUP_ALL
);
78 if (applyopts_single(fd
, popts
, PH_INIT
) < 0) return -1;
79 applyopts2(-1, popts
, PH_INIT
, PH_EARLY
);
81 retropt_bool(popts
, OPT_NOFORK
, &nofork
);
84 retropt_bool(popts
, OPT_PIPES
, &usepipes
);
86 retropt_bool(popts
, OPT_PTY
, &usebestpty
);
88 retropt_bool(popts
, OPT_OPENPTY
, &useopenpty
);
90 #if defined(HAVE_DEV_PTMX) || defined(HAVE_DEV_PTC)
91 retropt_bool(popts
, OPT_PTMX
, &useptmx
);
97 #if defined(HAVE_DEV_PTMX) || defined(HAVE_DEV_PTC)
101 if (usepipes
&& usepty
) {
102 Warn("_xioopen_foxec(): options \"pipes\" and \"pty\" must not be specified together; ignoring \"pipes\"");
105 #endif /* HAVE_PTY */
107 if (retropt_ushort(popts
, OPT_FDIN
, (unsigned short *)&fdi
) >= 0) {
108 if ((xioflags
&XIO_ACCMODE
) == XIO_RDONLY
) {
109 Error("_xioopen_foxec(): option fdin is useless in read-only mode");
112 if (retropt_ushort(popts
, OPT_FDOUT
, (unsigned short *)&fdo
) >= 0) {
113 if ((xioflags
&XIO_ACCMODE
) == XIO_WRONLY
) {
114 Error("_xioopen_foxec(): option fdout is useless in write-only mode");
119 if (!(xioflags
&XIO_MAYCHILD
)) {
120 Error("cannot fork off child process here");
121 /*!! free something */
124 fd
->flags
|= XIO_DOESCHILD
;
127 Notice2("forking off child, using %s for %s",
128 &("socket\0\0pipes\0\0\0pty\0\0\0\0\0"[(usepipes
<<3)|(usepty
<<4)]),
131 Notice2("forking off child, using %s for %s",
132 &("socket\0\0pipes\0\0\0"[(usepipes
<<3)]),
134 #endif /* HAVE_PTY */
136 applyopts(-1, popts
, PH_PREBIGEN
);
139 /*0 struct single *stream1, *stream2;*/
141 if (!(xioflags
& XIO_MAYEXEC
/* means exec+nofork */)) {
142 Error("option nofork is not allowed here");
143 /*!! free something */
146 fd
->flags
|= XIO_DOESEXEC
;
149 *copts
= moveopts(popts
, GROUP_ALL
);
152 if (sock1
->tag
== XIO_TAG_DUAL
) {
153 stream1
= &sock1
->dual
.stream
[0]->stream
;
154 stream2
= &sock1
->dual
.stream
[1]->stream
;
156 stream1
= &sock1
->stream
;
157 stream2
= &sock1
->stream
;
159 if (stream1
->dtype
== DATA_READLINE
|| stream2
->dtype
== DATA_READLINE
||
160 stream1
->dtype
== DATA_OPENSSL
|| stream2
->dtype
== DATA_OPENSSL
162 Error("with option nofork, openssl and readline in address1 do not work");
164 if (stream1
->lineterm
!= LINETERM_RAW
||
165 stream2
->lineterm
!= LINETERM_RAW
||
166 stream1
->ignoreeof
|| stream2
->ignoreeof
) {
167 Warn("due to option nofork, address1 options for lineterm and igoreeof do not apply");
171 /*! problem: when fdi==WRFD(sock[0]) or fdo==RDFD(sock[0]) */
172 if (rw
!= XIO_WRONLY
) {
173 if (XIO_GETRDFD(sock
[0]/*!!*/) == fdi
) {
174 if (Fcntl_l(fdi
, F_SETFD
, 0) < 0) {
175 Warn2("fcntl(%d, F_SETFD, 0): %s", fdi
, strerror(errno
));
177 if (Dup2(XIO_GETRDFD(sock
[0]), fdi
) < 0) {
178 Error3("dup2(%d, %d): %s",
179 XIO_GETRDFD(sock
[0]), fdi
, strerror(errno
));
181 /*0 Info2("dup2(%d, %d)", XIO_GETRDFD(sock[0]), fdi);*/
183 if (Dup2(XIO_GETRDFD(sock
[0]), fdi
) < 0) {
184 Error3("dup2(%d, %d): %s",
185 XIO_GETRDFD(sock
[0]), fdi
, strerror(errno
));
187 /*0 Info2("dup2(%d, %d)", XIO_GETRDFD(sock[0]), fdi);*/
190 if (rw
!= XIO_RDONLY
) {
191 if (XIO_GETWRFD(sock
[0]) == fdo
) {
192 if (Fcntl_l(fdo
, F_SETFD
, 0) < 0) {
193 Warn2("fcntl(%d, F_SETFD, 0): %s", fdo
, strerror(errno
));
195 if (Dup2(XIO_GETWRFD(sock
[0]), fdo
) < 0) {
196 Error3("dup2(%d, %d): %s)",
197 XIO_GETWRFD(sock
[0]), fdo
, strerror(errno
));
199 /*0 Info2("dup2(%d, %d)", XIO_GETWRFD(sock[0]), fdo);*/
201 if (Dup2(XIO_GETWRFD(sock
[0]), fdo
) < 0) {
202 Error3("dup2(%d, %d): %s)",
203 XIO_GETWRFD(sock
[0]), fdo
, strerror(errno
));
205 /*0 Info2("dup2(%d, %d)", XIO_GETWRFD(sock[0]), fdo);*/
212 #if defined(HAVE_DEV_PTMX)
213 # define PTMX "/dev/ptmx" /* Linux */
215 # define PTMX "/dev/ptc" /* AIX 4.3.3 */
217 fd
->dtype
= XIODATA_PTY
;
218 #if HAVE_DEV_PTMX || HAVE_DEV_PTC
219 if (usebestpty
|| useptmx
) {
220 if ((ptyfd
= Open(PTMX
, O_RDWR
|O_NOCTTY
, 0620)) < 0) {
221 Warn1("open(\""PTMX
"\", O_RDWR|O_NOCTTY, 0620): %s",
225 /*0 Info2("open(\"%s\", O_RDWR|O_NOCTTY, 0620) -> %d", PTMX, ptyfd);*/
227 if (ptyfd
>= 0 && ttyfd
< 0) {
229 /* we used PTMX before forking */
230 extern char *ptsname(int);
231 #if HAVE_GRANTPT /* AIX, not Linux */
232 if (Grantpt(ptyfd
)/*!*/ < 0) {
233 Warn2("grantpt(%d): %s", ptyfd
, strerror(errno
));
235 #endif /* HAVE_GRANTPT */
237 if (Unlockpt(ptyfd
)/*!*/ < 0) {
238 Warn2("unlockpt(%d): %s", ptyfd
, strerror(errno
));
240 #endif /* HAVE_UNLOCKPT */
241 #if HAVE_PROTOTYPE_LIB_ptsname /* AIX, not Linux */
242 if ((tn
= Ptsname(ptyfd
)) == NULL
) {
243 Warn2("ptsname(%d): %s", ptyfd
, strerror(errno
));
245 #endif /* HAVE_PROTOTYPE_LIB_ptsname */
247 if ((tn
= Ttyname(ptyfd
)) == NULL
) {
248 Error2("ttyname(%d): %s", ptyfd
, strerror(errno
));
251 ptyname
[0] = '\0'; strncat(ptyname
, tn
, MAXPTYNAMELEN
-1);
252 if ((ttyfd
= Open(tn
, O_RDWR
|O_NOCTTY
, 0620)) < 0) {
253 Warn2("open(\"%s\", O_RDWR|O_NOCTTY, 0620): %s", tn
, strerror(errno
));
255 /*0 Info2("open(\"%s\", O_RDWR|O_NOCTTY, 0620) -> %d", tn, ttyfd);*/
259 /* Linux: I_PUSH def'd; pty: ioctl(, I_FIND, ...) -> -1 EINVAL */
260 /* AIX: I_PUSH def'd; pty: ioctl(, I_FIND, ...) -> 1 */
261 /* SunOS: I_PUSH def'd; pty: ioctl(, I_FIND, ...) -> 0 */
262 /* HP-UX: I_PUSH def'd; pty: ioctl(, I_FIND, ...) -> 0 */
263 if (Ioctl(ttyfd
, I_FIND
, "ldterm") == 0) {
264 Ioctl(ttyfd
, I_PUSH
, "ptem"); /* 0 */
265 Ioctl(ttyfd
, I_PUSH
, "ldterm"); /* 0 */
266 Ioctl(ttyfd
, I_PUSH
, "ttcompat"); /* HP-UX: -1 */
270 #if 0 /* the following block need not work */
272 if (ttyfd
>= 0 && ((tn
= Ttyname(ttyfd
)) == NULL
)) {
273 Warn2("ttyname(%d): %s", ttyfd
, strerror(errno
));
276 Error("could not open pty");
280 Info1("opened pseudo terminal %s", tn
);
283 #endif /* HAVE_DEV_PTMX || HAVE_DEV_PTC */
287 if ((result
= Openpty(&ptyfd
, &ttyfd
, ptyname
, NULL
, NULL
)) < 0) {
288 Error4("openpty(%p, %p, %p, NULL, NULL): %s",
289 &ptyfd
, &ttyfd
, ptyname
, strerror(errno
));
293 #endif /* HAVE_OPENPTY */
295 if ((*copts
= moveopts(popts
, GROUP_TERMIOS
|GROUP_FORK
|GROUP_EXEC
|GROUP_PROCESS
)) == NULL
) {
298 applyopts_cloexec(ptyfd
, popts
);/*!*/
299 /* exec:...,pty did not kill child process under some circumstances */
300 if (fd
->howtoend
== END_UNSPEC
) {
301 fd
->howtoend
= END_CLOSE_KILL
;
304 /* this for parent, was after fork */
305 applyopts(ptyfd
, popts
, PH_FD
);
306 applyopts(ptyfd
, popts
, PH_LATE
);
307 if (applyopts_single(fd
, popts
, PH_LATE
) < 0) return -1;
311 /* this for child, was after fork */
312 applyopts(ttyfd
, *copts
, PH_FD
);
314 #endif /* HAVE_PTY */
316 struct opt
*popts2
, *copts2
;
319 fd
->dtype
= XIODATA_2PIPE
;
320 if (rw
!= XIO_WRONLY
) {
321 if (Pipe(rdpip
) < 0) {
322 Error2("pipe(%p): %s", rdpip
, strerror(errno
));
326 /*0 Info2("pipe({%d,%d})", rdpip[0], rdpip[1]);*/
327 /* rdpip[0]: read by socat; rdpip[1]: write by child */
329 if ((*copts
= moveopts(popts
, GROUP_FORK
|GROUP_EXEC
|GROUP_PROCESS
))
334 popts2
= copyopts(popts
, GROUP_ALL
);
335 copts2
= copyopts(*copts
, GROUP_ALL
);
337 if (rw
!= XIO_WRONLY
) {
338 applyopts_cloexec(rdpip
[0], popts
);
339 applyopts(rdpip
[0], popts
, PH_FD
);
340 applyopts(rdpip
[1], *copts
, PH_FD
);
343 if (rw
!= XIO_RDONLY
) {
344 if (Pipe(wrpip
) < 0) {
345 Error2("pipe(%p): %s", wrpip
, strerror(errno
));
349 /*0 Info2("pipe({%d,%d})", wrpip[0], wrpip[1]);*/
351 /* wrpip[1]: write by socat; wrpip[0]: read by child */
352 if (rw
!= XIO_RDONLY
) {
353 applyopts_cloexec(wrpip
[1], popts2
);
354 applyopts(wrpip
[1], popts2
, PH_FD
);
355 applyopts(wrpip
[0], copts2
, PH_FD
);
357 if (fd
->howtoend
== END_UNSPEC
) {
358 fd
->howtoend
= END_CLOSE_KILL
;
361 /* this for parent, was after fork */
363 case XIO_RDONLY
: fd
->fd
= rdpip
[0]; break;
364 case XIO_WRONLY
: fd
->fd
= wrpip
[1]; break;
365 case XIO_RDWR
: fd
->fd
= rdpip
[0];
366 fd
->para
.exec
.fdout
= wrpip
[1];
369 applyopts(fd
->fd
, popts
, PH_FD
);
370 applyopts(fd
->fd
, popts
, PH_LATE
);
371 if (applyopts_single(fd
, popts
, PH_LATE
) < 0) return -1;
374 retropt_int(popts
, OPT_PROTOCOL_FAMILY
, &d
);
375 result
= xiosocketpair(popts
, d
, SOCK_STREAM
, 0, sv
);
379 /*0 Info5("socketpair(%d, %d, %d, {%d,%d})",
380 d, type, protocol, sv[0], sv[1]);*/
382 if ((*copts
= moveopts(popts
, GROUP_FORK
|GROUP_EXEC
|GROUP_PROCESS
)) == NULL
) {
385 applyopts(sv
[0], *copts
, PH_PASTSOCKET
);
386 applyopts(sv
[1], popts
, PH_PASTSOCKET
);
388 applyopts_cloexec(sv
[0], *copts
);
389 applyopts(sv
[0], *copts
, PH_FD
);
390 applyopts(sv
[1], popts
, PH_FD
);
392 applyopts(sv
[0], *copts
, PH_PREBIND
);
393 applyopts(sv
[0], *copts
, PH_BIND
);
394 applyopts(sv
[0], *copts
, PH_PASTBIND
);
395 applyopts(sv
[1], popts
, PH_PREBIND
);
396 applyopts(sv
[1], popts
, PH_BIND
);
397 applyopts(sv
[1], popts
, PH_PASTBIND
);
399 if (fd
->howtoend
== END_UNSPEC
) {
400 fd
->howtoend
= END_SHUTDOWN_KILL
;
403 /* this for parent, was after fork */
405 applyopts(fd
->fd
, popts
, PH_FD
);
406 applyopts(fd
->fd
, popts
, PH_LATE
);
407 if (applyopts_single(fd
, popts
, PH_LATE
) < 0) return -1;
409 /*0 if ((optpr = copyopts(*copts, GROUP_PROCESS)) == NULL)
411 retropt_bool(*copts
, OPT_STDERR
, &withstderr
);
413 xiosetchilddied(); /* set SIGCHLD handler */
416 pid
= xio_fork(true, E_ERROR
);
421 if (!withfork
|| pid
== 0) { /* child */
426 /* The child should have default handling for SIGCHLD. */
427 /* In particular, it's not defined whether ignoring SIGCHLD is inheritable. */
428 if (Signal(SIGCHLD
, SIG_DFL
) == SIG_ERR
) {
429 Warn1("signal(SIGCHLD, SIG_DFL): %s", strerror(errno
));
435 if (rw
!= XIO_RDONLY
&& fdi
!= ttyfd
) {
436 if (Dup2(ttyfd
, fdi
) < 0) {
437 Error3("dup2(%d, %d): %s", ttyfd
, fdi
, strerror(errno
));
439 /*0 Info2("dup2(%d, %d)", ttyfd, fdi);*/
441 if (rw
!= XIO_WRONLY
&& fdo
!= ttyfd
) {
442 if (Dup2(ttyfd
, fdo
) < 0) {
443 Error3("dup2(%d, %d): %s", ttyfd
, fdo
, strerror(errno
));
445 /*0 Info2("dup2(%d, %d)", ttyfd, fdo);*/
447 if ((rw
== XIO_RDONLY
|| fdi
!= ttyfd
) &&
448 (rw
== XIO_WRONLY
|| fdo
!= ttyfd
)) {
449 applyopts_cloexec(ttyfd
, *copts
);
452 applyopts(ttyfd
, *copts
, PH_LATE
);
454 applyopts(ttyfd
, *copts
, PH_LATE2
);
456 #endif /* HAVE_PTY */
458 /* we might have a temporary conflict between what FDs are
459 currently allocated, and which are to be used. We try to find
460 a graceful solution via temporary descriptors */
463 if (rw
!= XIO_WRONLY
) Close(rdpip
[0]);
464 if (rw
!= XIO_RDONLY
) Close(wrpip
[1]);
465 if (fdi
== rdpip
[1]) { /* a conflict here */
466 if ((tmpi
= Dup(wrpip
[0])) < 0) {
467 Error2("dup(%d): %s", wrpip
[0], strerror(errno
));
470 /*0 Info2("dup(%d) -> %d", wrpip[0], tmpi);*/
473 if (fdo
== wrpip
[0]) { /* a conflict here */
474 if ((tmpo
= Dup(rdpip
[1])) < 0) {
475 Error2("dup(%d): %s", rdpip
[1], strerror(errno
));
478 /*0 Info2("dup(%d) -> %d", rdpip[1], tmpo);*/
482 if (rw
!= XIO_WRONLY
&& rdpip
[1] != fdo
) {
483 if (Dup2(rdpip
[1], fdo
) < 0) {
484 Error3("dup2(%d, %d): %s", rdpip
[1], fdo
, strerror(errno
));
488 /*0 Info2("dup2(%d, %d)", rdpip[1], fdo);*/
489 /*0 applyopts_cloexec(fdo, *copts);*/
491 if (rw
!= XIO_RDONLY
&& wrpip
[0] != fdi
) {
492 if (Dup2(wrpip
[0], fdi
) < 0) {
493 Error3("dup2(%d, %d): %s", wrpip
[0], fdi
, strerror(errno
));
497 /*0 Info2("dup2(%d, %d)", wrpip[0], fdi);*/
498 /*0 applyopts_cloexec(wrpip[0], *copts);*/ /* option is already consumed! */
499 /* applyopts_cloexec(fdi, *copts);*/ /* option is already consumed! */
502 applyopts(fdi
, *copts
, PH_LATE
);
503 applyopts(fdo
, *copts
, PH_LATE
);
504 applyopts(fdi
, *copts
, PH_LATE2
);
505 applyopts(fdo
, *copts
, PH_LATE2
);
507 } else { /* socketpair */
509 if (rw
!= XIO_RDONLY
&& fdi
!= sv
[1]) {
510 if (Dup2(sv
[1], fdi
) < 0) {
511 Error3("dup2(%d, %d): %s", sv
[1], fdi
, strerror(errno
));
513 /*0 Info2("dup2(%d, %d)", sv[1], fdi);*/
515 if (rw
!= XIO_WRONLY
&& fdo
!= sv
[1]) {
516 if (Dup2(sv
[1], fdo
) < 0) {
517 Error3("dup2(%d, %d): %s", sv
[1], fdo
, strerror(errno
));
519 /*0 Info2("dup2(%d, %d)", sv[1], fdo);*/
521 if (fdi
!= sv
[1] && fdo
!= sv
[1]) {
522 applyopts_cloexec(sv
[1], *copts
);
526 applyopts(fdi
, *copts
, PH_LATE
);
527 applyopts(fdi
, *copts
, PH_LATE2
);
531 applyopts(-1, *copts
, PH_LATE
);
532 applyopts(-1, *copts
, PH_LATE2
);
534 _xioopen_setdelayeduser();
535 /* set group before user - maybe you are not permitted afterwards */
536 if (retropt_gidt(*copts
, OPT_SETGID
, &group
) >= 0) {
539 if (retropt_uidt(*copts
, OPT_SETUID
, &user
) >= 0) {
548 return 0; /* indicate child process */
551 /* for parent (this is our socat process) */
552 Notice1("forked off child process "F_pid
, pid
);
555 if ((popts
= copyopts(*copts
,
556 GROUP_FD
|GROUP_TERMIOS
|GROUP_FORK
|GROUP_SOCKET
|GROUP_SOCK_UNIX
|GROUP_FIFO
)) == NULL
)
557 return STAT_RETRYLATER
;
562 if (Close(ttyfd
) < 0) {
563 Info2("close(%d): %s", ttyfd
, strerror(errno
));
566 #endif /* HAVE_PTY */
568 if (rw
== XIO_RDONLY
) Close(rdpip
[1]);
569 if (rw
== XIO_WRONLY
) Close(wrpip
[0]);
573 fd
->para
.exec
.pid
= pid
;
575 if (applyopts_single(fd
, popts
, PH_LATE
) < 0) return -1;
576 applyopts_signal(fd
, popts
);
577 if ((numleft
= leftopts(popts
)) > 0) {
578 Error1("%d option(s) could not be used", numleft
);
583 return pid
; /* indicate parent (main) process */
585 #endif /* WITH_EXEC || WITH_SYSTEM */
588 int setopt_path(struct opt
*opts
, char **path
) {
589 if (retropt_string(opts
, OPT_PATH
, path
) >= 0) {
590 if (setenv("PATH", *path
, 1) < 0) {
591 Error1("setenv(\"PATH\", \"%s\", 1): insufficient space", *path
);