Check for dup2 and use dup instead if we don't have it.
This commit is contained in:
@@ -101,6 +101,9 @@
|
|||||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||||
#undef HAVE_DLFCN_H
|
#undef HAVE_DLFCN_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `dup2' function. */
|
||||||
|
#undef HAVE_DUP2
|
||||||
|
|
||||||
/* Define to 1 if your glob.h defines the GLOB_BRACE and GLOB_TILDE flags. */
|
/* Define to 1 if your glob.h defines the GLOB_BRACE and GLOB_TILDE flags. */
|
||||||
#undef HAVE_EXTENDED_GLOB
|
#undef HAVE_EXTENDED_GLOB
|
||||||
|
|
||||||
|
3
configure
vendored
3
configure
vendored
@@ -15828,7 +15828,8 @@ LIBS=$ac_save_LIBS
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
for ac_func in strchr strrchr memchr memcpy memset sysconf tzset \
|
|
||||||
|
for ac_func in dup2 strchr strrchr memchr memcpy memset sysconf tzset \
|
||||||
strftime setrlimit initgroups getgroups fstat gettimeofday \
|
strftime setrlimit initgroups getgroups fstat gettimeofday \
|
||||||
regcomp setlocale getaddrinfo setsid setenv vhangup nanosleep
|
regcomp setlocale getaddrinfo setsid setenv vhangup nanosleep
|
||||||
do
|
do
|
||||||
|
@@ -1834,7 +1834,7 @@ dnl
|
|||||||
dnl Function checks
|
dnl Function checks
|
||||||
dnl
|
dnl
|
||||||
AC_FUNC_GETGROUPS
|
AC_FUNC_GETGROUPS
|
||||||
AC_CHECK_FUNCS(strchr strrchr memchr memcpy memset sysconf tzset \
|
AC_CHECK_FUNCS(dup2 strchr strrchr memchr memcpy memset sysconf tzset \
|
||||||
strftime setrlimit initgroups getgroups fstat gettimeofday \
|
strftime setrlimit initgroups getgroups fstat gettimeofday \
|
||||||
regcomp setlocale getaddrinfo setsid setenv vhangup nanosleep)
|
regcomp setlocale getaddrinfo setsid setenv vhangup nanosleep)
|
||||||
AC_CHECK_FUNCS(openpty, [AC_CHECK_HEADERS(util.h pty.h, [break])], [
|
AC_CHECK_FUNCS(openpty, [AC_CHECK_HEADERS(util.h pty.h, [break])], [
|
||||||
|
9
script.c
9
script.c
@@ -268,13 +268,22 @@ script_duplow(fd)
|
|||||||
/* sort fds so we can dup them safely */
|
/* sort fds so we can dup them safely */
|
||||||
for (i = 0; i < 5; i++)
|
for (i = 0; i < 5; i++)
|
||||||
indices[i] = i;
|
indices[i] = i;
|
||||||
|
/* XXX - qsort is overkill for this */
|
||||||
qsort(indices, 5, sizeof(int), fdcompar);
|
qsort(indices, 5, sizeof(int), fdcompar);
|
||||||
|
|
||||||
/* Move pty master/slave and session fds to low numbered fds. */
|
/* Move pty master/slave and session fds to low numbered fds. */
|
||||||
if (def_script) {
|
if (def_script) {
|
||||||
for (i = 0; i < 5; i++) {
|
for (i = 0; i < 5; i++) {
|
||||||
j = indices[i];
|
j = indices[i];
|
||||||
|
if (script_fds[j] != fd) {
|
||||||
|
#ifdef HAVE_DUP2
|
||||||
dup2(script_fds[j], fd);
|
dup2(script_fds[j], fd);
|
||||||
|
#else
|
||||||
|
close(fd);
|
||||||
|
dup(script_fds[j]);
|
||||||
|
close(script_fds[j]);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
script_fds[j] = fd++;
|
script_fds[j] = fd++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user