summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSam Hartman <hartmans@mit.edu>1996-04-15 07:15:11 +0000
committerSam Hartman <hartmans@mit.edu>1996-04-15 07:15:11 +0000
commitceec1f1b7a94e9219b7be17586db83f76d39c666 (patch)
tree0a80e96c20c09d932039503bc450504bceee618a /src
parent979c2a05adac56aaf0c19b34337e745795a52d97 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/util/pty/ChangeLog13
-rw-r--r--src/util/pty/README5
-rw-r--r--src/util/pty/cleanup.c46
-rw-r--r--src/util/pty/configure.in3
-rw-r--r--src/util/pty/pty-int.h1
5 files changed, 62 insertions, 6 deletions
diff --git a/src/util/pty/ChangeLog b/src/util/pty/ChangeLog
index 10791a9151..b5c6cd55e9 100644
--- a/src/util/pty/ChangeLog
+++ b/src/util/pty/ChangeLog
@@ -1,3 +1,16 @@
+Sun Apr 14 00:36:33 1996 Sam Hartman <hartmans@mit.edu>
+
+ * pty-int.h: Don't include sys/wait.h here.
+
+ * configure.in : Check for waitpid.
+
+Sat Apr 13 18:58:43 1996 Sam Hartman <hartmans@mit.edu>
+
+ * 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 <hartmans@tertius.mit.edu>
* configure.in : Do streams handling by deciding what modules to
diff --git a/src/util/pty/README b/src/util/pty/README
index 937e3d44a5..8d906343b7 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 31522a47eb..0e9104ef94 100644
--- a/src/util/pty/cleanup.c
+++ b/src/util/pty/cleanup.c
@@ -20,6 +20,9 @@
#include <com_err.h>
#include "libpty.h"
#include "pty-int.h"
+#ifdef HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#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 f2673a48bb..683b6b9590 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 4b6d1570de..d4d225cfe8 100644
--- a/src/util/pty/pty-int.h
+++ b/src/util/pty/pty-int.h
@@ -23,7 +23,6 @@
#include <sys/stat.h>
#include <sys/ioctl.h>
-#include <sys/wait.h>
#include <sys/file.h>
#include <sys/time.h>
#include <ctype.h>