* pty master close and SIGHUP
@ 2004-07-16 14:31 Albert Cahalan
0 siblings, 0 replies; only message in thread
From: Albert Cahalan @ 2004-07-16 14:31 UTC (permalink / raw)
To: linux-kernel mailing list; +Cc: aebr
Something is wrong with the kernel, or maybe with this:
http://www.win.tue.nl/~aeb/linux/lk/lk-12.html#ss10.3.4
As I recall, the SIGHUP is sent by the kernel itself when
the master is closed or the session leader dies. I think
there is a credentials problem in the kernel now, with the
signal being sent as if the master-side process or session
leader had sent it. I do indeed find a check_kill_permission()
call that ought not be made AFAIK. The TTY code makes an
effort to force the SIGHUP, but this gets ignored. Maybe
some "cleanup" tried to share common code?
Here's an example. First, I start an xterm. Then in that
xterm, I use "su -" to become root and I start "top".
The processes now look like this:
$ ps -p 7204 -t pts/25 -o euid,ruid,tty,sess,pgrp,ppid,pid,tpgid,stat,pcpu,comm
EUID RUID TT SESS PGRP PPID PID TPGID STAT %CPU COMMAND
1000 1000 ? 7196 7204 1 7204 -1 S 0.0 xterm
1000 1000 pts/25 7205 7205 7204 7205 7218 Ss 0.0 bash
0 0 pts/25 7205 7213 7205 7213 7218 S 0.0 bash
0 0 pts/25 7205 7218 7213 7218 7218 S+ 1.3 top
As you can see, the session leader is bash #7204 and top
is the sole process in the foreground process group.
Now I close the xterm. It dies. The session leader also dies.
This should then cause all processes in the foreground process
group to get SIGHUP. If top gets SIGHUP, it shuts down. This
all works great normally, but see what happens when top is
running as root:
$ ps -p 7204 -s 7205 -o euid,ruid,tty,sess,pgrp,ppid,pid,tpgid,stat,pcpu,comm
EUID RUID TT SESS PGRP PPID PID TPGID STAT %CPU COMMAND
0 0 ? 7205 7213 1 7213 -1 S 0.0 bash
0 0 ? 7205 7218 7213 7218 -1 R 51.4 top
The SIGHUP is never delivered.
Now I know it isn't really clean to let top spin calling select()
when the tty goes away, but SIGHUP should take care of that.
Where is my SIGHUP?
I recall the rules being even looser traditionally, pretty much
allowing you to send signals (at least some of them) to anything
on your tty or in your session. Was there a SysV/BSD/POSIX
disagreement over this?
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2004-07-16 16:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-16 14:31 pty master close and SIGHUP Albert Cahalan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox