Petr Ostadal
2002-Oct-11 10:44 UTC
Why openssh newer than 2.9.9 doesn't send SIGTERM and SIGHUP to child process?
Hi, I search in archive list if there any reason why is removed in openssh newer than 2.9.9 from function 'void session_close_by_channel(int id, void *arg)' sending of SIGTEMR and SIGHUP signals to child as was in 2.9.9 version? See follow sniped code from 2.9.9 sources: ---- openssh-2.9.9/session.c ---------------------------------------- void session_close_by_channel(int id, void *arg) ... debug("session_close_by_channel: channel %d kill %d", id, s->pid); if (s->pid == 0) { /* close session immediately */ session_close(s); } else { /* notify child, delay session cleanup */ if (kill(s->pid, (s->ttyfd == -1) ? SIGTERM : SIGHUP) < 0) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error("session_close_by_channel: kill %d: %s", s->pid, strerror(errno)); } ... ---------------------------------------------------------------------------- This change in new version cause that some process (which doesn't need terminal) hanged after termination ssh by e.g. SIGINT, becouse hanged process doesn't receive any signal from ssh process. basilisk:~> ssh basilisk 'sleep 1000' 23022: Killed by signal 2. basilisk:~> ps -ef |grep sleep postadal 23026 1 1 12:30 ? 00:00:00 sleep 100 The problem above can resolve Force pseudo-tty allocation (option -t), but it is not ideal solution. Please, could anyone tell me why the new openssh doesn't send SIGHUP to child process if ssh was terminated ? Thnx in advance Petr -- Best Regards / S pozdravem, Petr Ostadal developer --------------------------------------------------------------------- SuSE CR, s.r.o. e-mail: postadal at suse.cz Drahobejlova 27 tel: +420 2 9654 2382 190 00 Praha 9 fax: +420 2 9654 2374 Czech Republic http://www.suse.cz
Markus Friedl
2002-Oct-11 11:08 UTC
Why openssh newer than 2.9.9 doesn't send SIGTERM and SIGHUP to child process?
because it was wrong (telnetd, rlogind don't do it) and dangerous (sending signals as root to other processes). the login shells should die if their stdin/out is closed. did you check the cvs log for this change? On Fri, Oct 11, 2002 at 12:44:46PM +0200, Petr Ostadal wrote:> Hi, > > I search in archive list if there any reason why is removed in openssh > newer than 2.9.9 from function > 'void session_close_by_channel(int id, void *arg)' sending of SIGTEMR and > SIGHUP signals to child as was in 2.9.9 version? See follow sniped code > from 2.9.9 sources: > > ---- openssh-2.9.9/session.c ---------------------------------------- > void > session_close_by_channel(int id, void *arg) > ... > debug("session_close_by_channel: channel %d kill %d", id, s->pid); > if (s->pid == 0) { > /* close session immediately */ > session_close(s); > } else { > /* notify child, delay session cleanup */ > if (kill(s->pid, (s->ttyfd == -1) ? SIGTERM : SIGHUP) < 0) > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > error("session_close_by_channel: kill %d: %s", > s->pid, strerror(errno)); > } > ... > > ---------------------------------------------------------------------------- > > This change in new version cause that some process (which doesn't need > terminal) hanged after termination ssh by e.g. SIGINT, becouse hanged > process doesn't receive any signal from ssh process. > > basilisk:~> ssh basilisk 'sleep 1000' > 23022: Killed by signal 2. > basilisk:~> ps -ef |grep sleep > postadal 23026 1 1 12:30 ? 00:00:00 sleep 100 > > The problem above can resolve Force pseudo-tty allocation (option -t), but > it is not ideal solution. > > Please, could anyone tell me why the new openssh doesn't send SIGHUP to > child process if ssh was terminated ? > > Thnx in advance > > Petr > > -- > Best Regards / S pozdravem, > > Petr Ostadal > developer > --------------------------------------------------------------------- > SuSE CR, s.r.o. e-mail: postadal at suse.cz > Drahobejlova 27 tel: +420 2 9654 2382 > 190 00 Praha 9 fax: +420 2 9654 2374 > Czech Republic http://www.suse.cz > > _______________________________________________ > openssh-unix-dev at mindrot.org mailing list > http://www.mindrot.org/mailman/listinfo/openssh-unix-dev
Darren Tucker
2002-Oct-11 11:36 UTC
Why openssh newer than 2.9.9 doesn't send SIGTERM and SIGHUP tochild process?
Petr Ostadal wrote:> The problem above can resolve Force pseudo-tty allocation (option -t), but > it is not ideal solution. > > Please, could anyone tell me why the new openssh doesn't send SIGHUP to > child process if ssh was terminated ?I don't know why it was removed (in fact, I didn't know about it at all until I read your message) but I've got an open bug on a similar issue: http://bugzilla.mindrot.org/show_bug.cgi?id=396 The line you're referring to was removed from session.c between 2.9.9p2 and 3.0 in an OpenBSD sync: revision 1.153 date: 2001/10/12 01:35:06; author: djm; state: Exp; lines: +11 -18 - (djm) OpenBSD CVS Sync - markus at cvs.openbsd.org 2001/10/10 22:18:47 [channels.c channels.h clientloop.c nchan.c serverloop.c] [session.c session.h] try to keep channels open until an exit-status message is sent. don't kill the login shells if the shells stdin/out/err is closed. this should now work: ssh -2n localhost 'exec > /dev/null 2>&1; sleep 10; exit 5'; echo ? -- Darren Tucker (dtucker at zip.com.au) GPG key 8FF4FA69 / D9A3 86E9 7EEE AF4B B2D4 37C9 C982 80C7 8FF4 FA69 Good judgement comes with experience. Unfortunately, the experience usually comes from bad judgement.