summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed T. Crigler <crigler@users.sourceforge.net>2004-06-23 04:48:07 +0000
committerNed T. Crigler <crigler@users.sourceforge.net>2004-06-23 04:48:07 +0000
commit302917ca33d7cdfac786f562986b2c669f64ad49 (patch)
tree82de1acece2bd17786098290349f9153247d2cdf
parent79b7d83ede3d7f9daf601a747c449540f22b8237 (diff)
First attempt at proper process group handling.
-rw-r--r--master.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/master.c b/master.c
index 8a43e74..8d31651 100644
--- a/master.c
+++ b/master.c
@@ -201,6 +201,35 @@ control_activity(int s)
*(p->pprev) = p;
}
+/* Send a signal to the slave side of a pseudo-terminal. */
+static void
+killpty(struct pty *pty, int sig)
+{
+ pid_t pgrp = -1;
+
+#ifdef TIOCSIGNAL
+ if (ioctl(pty->fd, TIOCSIGNAL, sig) >= 0)
+ return;
+#endif
+#ifdef TIOCSIG
+ if (ioctl(pty->fd, TIOCSIG, sig) >= 0)
+ return;
+#endif
+#ifdef TIOCGPGRP
+#ifdef BROKEN_MASTER
+ if (ioctl(pty->slave, TIOCGPGRP, &pgrp) >= 0 && pgrp != -1 &&
+ kill(-pgrp, sig) >= 0)
+ return;
+#endif
+ if (ioctl(pty->fd, TIOCGPGRP, &pgrp) >= 0 && pgrp != -1 &&
+ kill(-pgrp, sig) >= 0)
+ return;
+#endif
+
+ /* Fallback using the child's pid. */
+ kill(-pty->pid, sig);
+}
+
/* Process activity from a client. */
static void
client_activity(struct client *p)
@@ -241,7 +270,7 @@ client_activity(struct client *p)
ioctl(the_pty.fd, TIOCSWINSZ, &the_pty.ws);
}
else
- kill(-the_pty.pid, SIGWINCH);
+ killpty(&the_pty, SIGWINCH);
}
else if (pkt.type == MSG_DETACH)
p->attached = 0;