diff options
| author | Ned T. Crigler <crigler@users.sourceforge.net> | 2004-06-23 04:48:07 +0000 |
|---|---|---|
| committer | Ned T. Crigler <crigler@users.sourceforge.net> | 2004-06-23 04:48:07 +0000 |
| commit | 302917ca33d7cdfac786f562986b2c669f64ad49 (patch) | |
| tree | 82de1acece2bd17786098290349f9153247d2cdf /master.c | |
| parent | 79b7d83ede3d7f9daf601a747c449540f22b8237 (diff) | |
First attempt at proper process group handling.
Diffstat (limited to 'master.c')
| -rw-r--r-- | master.c | 31 |
1 files changed, 30 insertions, 1 deletions
@@ -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; |
