+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
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.
#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;
}
#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
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
#include <sys/stat.h>
#include <sys/ioctl.h>
-#include <sys/wait.h>
#include <sys/file.h>
#include <sys/time.h>
#include <ctype.h>