projects
/
sbcl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
1.0.39.4: fix build on non-darwin and ppc/darwin platforms
[sbcl.git]
/
src
/
runtime
/
run-program.c
diff --git
a/src/runtime/run-program.c
b/src/runtime/run-program.c
index
6b7575c
..
d1d98e6
100644
(file)
--- a/
src/runtime/run-program.c
+++ b/
src/runtime/run-program.c
@@
-55,7
+55,7
@@
int set_noecho(int fd)
}
extern char **environ;
}
extern char **environ;
-int spawn(char *program, char *argv[], int stdin, int stdout, int stderr,
+int spawn(char *program, char *argv[], int sin, int sout, int serr,
int search, char *envp[], char *pty_name, int wait)
{
int pid = fork();
int search, char *envp[], char *pty_name, int wait)
{
int pid = fork();
@@
-65,16
+65,22
@@
int spawn(char *program, char *argv[], int stdin, int stdout, int stderr,
if (pid != 0)
return pid;
if (pid != 0)
return pid;
- /* Put us in our own process group. */
-#if defined(hpux)
- setsid();
+ /* Put us in our own process group, but only if we need not
+ * share stdin with our parent. In the latter case we claim
+ * control of the terminal. */
+ if (sin >= 0) {
+#if defined(LISP_FEATURE_HPUX)
+ setsid();
#elif defined(LISP_FEATURE_DARWIN)
#elif defined(LISP_FEATURE_DARWIN)
- setpgid(0, getpid());
+ setpgid(0, getpid());
#elif defined(SVR4) || defined(__linux__) || defined(__osf__)
#elif defined(SVR4) || defined(__linux__) || defined(__osf__)
- setpgrp();
+ setpgrp();
#else
#else
- setpgrp(0, getpid());
+ setpgrp(0, getpid());
#endif
#endif
+ } else {
+ tcsetpgrp(0, getpgrp());
+ }
/* unblock signals */
sigemptyset(&sset);
/* unblock signals */
sigemptyset(&sset);
@@
-82,7
+88,7
@@
int spawn(char *program, char *argv[], int stdin, int stdout, int stderr,
/* If we are supposed to be part of some other pty, go for it. */
if (pty_name) {
/* If we are supposed to be part of some other pty, go for it. */
if (pty_name) {
-#if !defined(hpux) && !defined(SVR4)
+#if !defined(LISP_FEATURE_HPUX) && !defined(SVR4)
fd = open("/dev/tty", O_RDWR, 0);
if (fd >= 0) {
ioctl(fd, TIOCNOTTY, 0);
fd = open("/dev/tty", O_RDWR, 0);
if (fd >= 0) {
ioctl(fd, TIOCNOTTY, 0);
@@
-97,12
+103,12
@@
int spawn(char *program, char *argv[], int stdin, int stdout, int stderr,
close(fd);
} else{
/* Set up stdin, stdout, and stderr */
close(fd);
} else{
/* Set up stdin, stdout, and stderr */
- if (stdin >= 0)
- dup2(stdin, 0);
- if (stdout >= 0)
- dup2(stdout, 1);
- if (stderr >= 0)
- dup2(stderr, 2);
+ if (sin >= 0)
+ dup2(sin, 0);
+ if (sout >= 0)
+ dup2(sout, 1);
+ if (serr >= 0)
+ dup2(serr, 2);
}
/* Close all other fds. */
#ifdef SVR4
}
/* Close all other fds. */
#ifdef SVR4