From: Sam Hartman Date: Mon, 15 Apr 1996 07:15:11 +0000 (+0000) Subject: Have pty_cleanup() fork on systems with vhangup() X-Git-Tag: krb5-1.0-beta6~205 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=ceec1f1b7a94e9219b7be17586db83f76d39c666;p=krb5.git Have pty_cleanup() fork on systems with vhangup() so that the right controlling terminal can be used; needed on HP and others possibly. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@7813 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/util/pty/ChangeLog b/src/util/pty/ChangeLog index 10791a915..b5c6cd55e 100644 --- a/src/util/pty/ChangeLog +++ b/src/util/pty/ChangeLog @@ -1,3 +1,16 @@ +Sun Apr 14 00:36:33 1996 Sam Hartman + + * pty-int.h: Don't include sys/wait.h here. + + * configure.in : Check for waitpid. + +Sat Apr 13 18:58:43 1996 Sam Hartman + + * cleanup.c (pty_cleanup): If we are doing a vhangup, then fork + and dissociate on hangup. This makes the HP happy, because there + is no way to get rid of a controlling terminal besides setsid() on + the HP. + Sun Mar 24 19:59:14 1996 Sam Hartman * configure.in : Do streams handling by deciding what modules to diff --git a/src/util/pty/README b/src/util/pty/README index 937e3d44a..8d906343b 100644 --- a/src/util/pty/README +++ b/src/util/pty/README @@ -99,7 +99,10 @@ long pty_cleanup(char *slave, pid_t pid, int update_wtmp) the pty, HUPing processes associated with it. (pid is the pid of the slave process that may have died, slave is the name of the slave terminal.) PID is allowed to be zero if unknown; this may disable -some cleanup operations. +some cleanup operations. This routine may fork on some systems. As +such, SIGCHLD may be generated and blocked for some time during the +routine. In addition, on systems without waitpid() or wait4(), wait() +may be called. diff --git a/src/util/pty/cleanup.c b/src/util/pty/cleanup.c index 31522a47e..0e9104ef9 100644 --- a/src/util/pty/cleanup.c +++ b/src/util/pty/cleanup.c @@ -20,6 +20,9 @@ #include #include "libpty.h" #include "pty-int.h" +#ifdef HAVE_SYS_WAIT_H +#include +#endif long pty_cleanup (slave, pid, update_utmp) char *slave; @@ -53,9 +56,46 @@ long pty_cleanup (slave, pid, update_utmp) } #else /* HAVE_REVOKE*/ #ifdef VHANG_LAST - if ( retval = ( pty_open_ctty( slave, &fd ))) - return retval; - ptyint_vhangup(); + { + int status; +#ifdef POSIX_SIGNALS + sigset_t old, new; + sigemptyset(&new); + sigaddset(&new, SIGCHLD); + sigprocmask ( SIG_BLOCK, &new, &old); +#else /*POSIX_SIGNALS*/ + int mask = sigblock(sigmask(SIGCHLD)); +#endif /*POSIX_SIGNALS*/ + switch (retval = fork()) { + case -1: +#ifdef POSIX_SIGNALS + sigprocmask(SIG_SETMASK, &old, 0); +#else /*POSIX_SIGNALS*/ + sigsetmask(mask); +#endif /*POSIX_SIGNALS*/ + return errno; + case 0: + ptyint_void_association(); + if ( retval = ( pty_open_ctty( slave, &fd ))) + exit(retval); + ptyint_vhangup(); + exit(0); + break; + default: +#ifdef HAVE_WAITPID + waitpid(retval, &status, 0); +#else /*HAVE_WAITPID*/ + wait(&status); +#endif +#ifdef POSIX_SIGNALS + sigprocmask(SIG_SETMASK, &old, 0); +#else /*POSIX_SIGNALS*/ + sigsetmask(mask); +#endif /*POSIX_SIGNALS*/ + + break; + } + } #endif /*VHANG_LAST*/ #endif /* HAVE_REVOKE*/ #ifndef HAVE_STREAMS diff --git a/src/util/pty/configure.in b/src/util/pty/configure.in index f2673a48b..683b6b959 100644 --- a/src/util/pty/configure.in +++ b/src/util/pty/configure.in @@ -63,7 +63,8 @@ AC_FUNC_CHECK(grantpt,AC_DEFINE(HAVE_GRANTPT)) AC_FUNC_CHECK(openpty,AC_DEFINE(HAVE_OPENPTY)) AC_FUNC_CHECK(logwtmp,AC_DEFINE(HAVE_LOGWTMP)) AC_CHECK_HEADERS(unistd.h stdlib.h string.h utmpx.h utmp.h sys/filio.h sys/sockio.h sys/label.h sys/tty.h ttyent.h lastlog.h sys/select.h sys/ptyvar.h) -AC_REPLACE_FUNCS(getdtablesize) +AC_CHECK_HEADERS(sys/wait.h) +AC_CHECK_FUNCS(waitpid) DECLARE_SYS_ERRLIST KRB5_SIGTYPE CHECK_SIGNALS diff --git a/src/util/pty/pty-int.h b/src/util/pty/pty-int.h index 4b6d1570d..d4d225cfe 100644 --- a/src/util/pty/pty-int.h +++ b/src/util/pty/pty-int.h @@ -23,7 +23,6 @@ #include #include -#include #include #include #include