[Bug 652633] New: systemd: shutdown doesn't properly kill shell
https://bugzilla.novell.com/show_bug.cgi?id=652633 https://bugzilla.novell.com/show_bug.cgi?id=652633#c0 Summary: systemd: shutdown doesn't properly kill shell Classification: openSUSE Product: openSUSE 11.4 Version: Factory Platform: Other OS/Version: Other Status: NEW Severity: Normal Priority: P5 - None Component: Basesystem AssignedTo: kasievers@novell.com ReportedBy: lnussel@novell.com QAContact: qa@suse.de CC: aj@novell.com Found By: --- Blocker: --- when logged in at the text console and the system is ordered to shut down the shell does not seem to get killed gracefully. The shell history is not saved to disk. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=652633
https://bugzilla.novell.com/show_bug.cgi?id=652633#c1
--- Comment #1 from Kay Sievers
https://bugzilla.novell.com/show_bug.cgi?id=652633
https://bugzilla.novell.com/show_bug.cgi?id=652633#c2
Kay Sievers
https://bugzilla.novell.com/show_bug.cgi?id=652633
https://bugzilla.novell.com/show_bug.cgi?id=652633#c3
Kay Sievers
https://bugzilla.novell.com/show_bug.cgi?id=652633
https://bugzilla.novell.com/show_bug.cgi?id=652633#c4
Dr. Werner Fink
https://bugzilla.novell.com/show_bug.cgi?id=652633
https://bugzilla.novell.com/show_bug.cgi?id=652633#c5
--- Comment #5 from Jiri Slaby
... and AFAICR this does not happen with sysvinit. The question rises: is it possible for the shell to save its history. Or do you have an strace around to see if the signals will reach the shell in the correct order (SIGTERM, SIGHUP) and the shell has the possiblity and enough time to save its history to disk *before* the final SIGKILL and umounting the file system.
Strace is killed too. So I did: trap 'echo TERM >/dev/ttyS0' SIGTERM trap 'echo INT >/dev/ttyS0' SIGINT trap 'echo HUP >/dev/ttyS0' SIGHUP And only TERM is printed. Then KILL probably happens. How fast do you send KILL after TERM in systemd? -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=652633
https://bugzilla.novell.com/show_bug.cgi?id=652633#c6
--- Comment #6 from Jiri Slaby
And only TERM is printed. Then KILL probably happens. How fast do you send KILL after TERM in systemd?
Oh, got it. 'kill -TERM' does nothing to bash. Only 'kill -HUP' shuts it down gracefully... -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=652633
https://bugzilla.novell.com/show_bug.cgi?id=652633#c7
--- Comment #7 from Jiri Slaby
https://bugzilla.novell.com/show_bug.cgi?id=652633
https://bugzilla.novell.com/show_bug.cgi?id=652633#c8
--- Comment #8 from Dr. Werner Fink
https://bugzilla.novell.com/show_bug.cgi?id=652633
https://bugzilla.novell.com/show_bug.cgi?id=652633#c9
--- Comment #9 from Jiri Slaby
I'm wondering why the signal USR2 is send to the bash, this will cause the shell to exit without a trap.
Yes, if I send USR2 to the bash, it saves its history and exits... Just an excerpt from the bash manpage: When bash is interactive, in the absence of any traps, it ignores SIGTERM (so that kill 0 does not kill an interactive shell), and SIGINT is caught and handled (so that the wait builtin is interruptible). In all cases, bash ignores SIGQUIT. If job control is in effect, bash ignores SIGTTIN, SIGTTOU, and SIGTSTP.
You may try out if a simple trap on USR2 may help to save the history.
I don't understand this... -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=652633
https://bugzilla.novell.com/show_bug.cgi?id=652633#c10
--- Comment #10 from Dr. Werner Fink
I don't understand this...
You may try out trap 'history -a' SIGURS2 to see if this does help. Beside this: what does test -w $HISTFILE || echo $HISTFILE not writable show? -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=652633
https://bugzilla.novell.com/show_bug.cgi?id=652633#c11
Kay Sievers
Hmmm ... AFAICS from source of util-linux-2.19-rc1 from factory the signal handler at http://git.kernel.org/ is identical with those of util-linux-2.19-rc1
SUSE ships its own "login": $ rpm -qf /bin/login login-4.0-5.1.x86_64 Just log into a getty, kill the spawned "login" from another shell, and watch the bash child of "login" to just stay around. If I replace SUSE's "login" with the one from util-linux all works as expected. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=652633
https://bugzilla.novell.com/show_bug.cgi?id=652633#c12
--- Comment #12 from Jiri Slaby
trap 'history -a' SIGURS2
This makes no difference.
to see if this does help. Beside this: what does
test -w $HISTFILE || echo $HISTFILE not writable
show?
Nothing... -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=652633
https://bugzilla.novell.com/show_bug.cgi?id=652633#c13
--- Comment #13 from Jiri Slaby
(In reply to comment #10)
trap 'history -a' SIGURS2
This makes no difference.
Hmm, after this XXX is shown 3 times in the history file: my_trap () { echo $aa >/dev/ttyS0 if test -w $HISTFILE; then echo $HISTFILE writable >/dev/ttyS0 echo XXX >>$HISTFILE 2>/dev/ttyS0 else echo $HISTFILE NOT writable >/dev/ttyS0 fi } for aa in `seq 0 31`; do trap "my_trap $aa" $aa done -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=652633
https://bugzilla.novell.com/show_bug.cgi?id=652633#c14
--- Comment #14 from Dr. Werner Fink
https://bugzilla.novell.com/show_bug.cgi?id=652633
https://bugzilla.novell.com/show_bug.cgi?id=652633#c15
Dr. Werner Fink
https://bugzilla.novell.com/show_bug.cgi?id=652633
https://bugzilla.novell.com/show_bug.cgi?id=652633#c16
Dr. Werner Fink
https://bugzilla.novell.com/show_bug.cgi?id=652633
https://bugzilla.novell.com/show_bug.cgi?id=652633#c17
--- Comment #17 from Kay Sievers
https://bugzilla.novell.com/show_bug.cgi?id=652633
https://bugzilla.novell.com/show_bug.cgi?id=652633#c18
Thorsten Kukuk
https://bugzilla.novell.com/show_bug.cgi?id=652633
https://bugzilla.novell.com/show_bug.cgi?id=652633#c19
--- Comment #19 from Kay Sievers
Kay, why should the new signal handler be correct?
How you mean? Just like it behaves with your patch, just that "login" also terminates on SIGTERM, to not to need to add custom stuff to getty service files.
login explicit creates a new session for the child so that the signals will not be forwarded.
If "login" is killed, it should kill its child, easy at that. There is no need to leave bash hanging around to get killed as an unexpected process to cleanup. If you don't like the forwarding, maybe use: prctl(PR_SET_PDEATHSIG, SIGHUP); But I'm not sure if that is necessary to fiddle around with.
Now we do everything to make that useless. Some expectations are wrong here. And with the people I spoke now, everyboday says that login should NOT forward that signals.
Yeah, just use the login from util-linux, and forget about everything. :) -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=652633
https://bugzilla.novell.com/show_bug.cgi?id=652633#c20
--- Comment #20 from Dr. Werner Fink
https://bugzilla.novell.com/show_bug.cgi?id=652633
https://bugzilla.novell.com/show_bug.cgi?id=652633#c21
--- Comment #21 from Dr. Werner Fink
https://bugzilla.novell.com/show_bug.cgi?id=652633
https://bugzilla.novell.com/show_bug.cgi?id=652633#c22
--- Comment #22 from Thorsten Kukuk
If "login" is killed, it should kill its child, easy at that.
Why should it? Please come with real arguments, not only because you think it should so. login, especially the one from util-linux, did create a new session so that this does not happen.
Yeah, just use the login from util-linux, and forget about everything. :)
Only because it got a patch with matches with what you like? That it is from util-linux does not mean it is correct ... Looking at the login sources of BSD and other: nobody is forwarding the signal and killing the shell. The only implemenation I found is the one from util-linux ... -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=652633
https://bugzilla.novell.com/show_bug.cgi?id=652633#c23
--- Comment #23 from Dr. Werner Fink
https://bugzilla.novell.com/show_bug.cgi?id=652633
https://bugzilla.novell.com/show_bug.cgi?id=652633#c24
Kay Sievers
(In reply to comment #19)
If "login" is killed, it should kill its child, easy at that.
Why should it? Please come with real arguments, not only because you think it should so. login, especially the one from util-linux, did create a new session so that this does not happen.
It does here. How about trying it?
Yeah, just use the login from util-linux, and forget about everything. :)
Only because it got a patch with matches with what you like? That it is from util-linux does not mean it is correct ...
Looking at the login sources of BSD and other: nobody is forwarding the signal and killing the shell. The only implemenation I found is the one from util-linux ...
Sure, and that's what makes the most sense to me. I guess, instead you should justify what's the gain for SUSE not to use the maintained version in util-linux like others, but maintain their own code instead. And also what's so nice about leaving and orphaned bash hanging around. :) -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=652633
https://bugzilla.novell.com/show_bug.cgi?id=652633#c25
Thorsten Kukuk
(In reply to comment #22)
(In reply to comment #19)
If "login" is killed, it should kill its child, easy at that.
Why should it? Please come with real arguments, not only because you think it should so. login, especially the one from util-linux, did create a new session so that this does not happen.
It does here. How about trying it?
Yes, it introduced several years ago a new session, so that the signals are not forwarded, and now it adds code which makes that change useless.
Looking at the login sources of BSD and other: nobody is forwarding the signal and killing the shell. The only implemenation I found is the one from util-linux ...
Sure, and that's what makes the most sense to me.
I guess, instead you should justify what's the gain for SUSE not to use the maintained version in util-linux like others, but maintain their own code instead. And also what's so nice about leaving and orphaned bash hanging around. :)
No, I'm still waiting for arguments from you. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=652633
https://bugzilla.novell.com/show_bug.cgi?id=652633#c26
Kay Sievers
(In reply to comment #19)
There is no lastlog tool found in util-linux which is a major feature of pam-login.
If that's useful and not already covered, please just add it to util-linux instead of a SUSE package. We really should stop playing these games here. At a larger scale, we do nobody a favor with all these SUSE-only patches and packages. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=652633
https://bugzilla.novell.com/show_bug.cgi?id=652633#c28
Kay Sievers
around. :)
No, I'm still waiting for arguments from you.
I fail to see what's so hard to understand here. Orphaned processes just don't make much sense, as you can see here with the lost history. Login has spawned the shell as its _child_, not as a _service_, so it should clean it up if it dies itself -- be it a session or not. I already spent far too much time with this. Please take care, or close the bug, if you don't want to fix it. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=652633
https://bugzilla.novell.com/show_bug.cgi?id=652633#c29
--- Comment #29 from Dr. Werner Fink
https://bugzilla.novell.com/show_bug.cgi?id=652633
https://bugzilla.novell.com/show_bug.cgi?id=652633#c30
--- Comment #30 from Kay Sievers
Kay: My question is why is login able to signal a session leader, that is that login is able to send SIGHUP *after* setsid().
Because it has forked it as a child without re-parenting, and still belongs to the "login/getty" service. That child should follow his parent when the system tells the service to terminate. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=652633
https://bugzilla.novell.com/show_bug.cgi?id=652633#c31
--- Comment #31 from Kay Sievers
https://bugzilla.novell.com/show_bug.cgi?id=652633
https://bugzilla.novell.com/show_bug.cgi?id=652633#c32
--- Comment #32 from Dr. Werner Fink
https://bugzilla.novell.com/show_bug.cgi?id=652633
https://bugzilla.novell.com/show_bug.cgi?id=652633#c33
--- Comment #33 from Dr. Werner Fink
https://bugzilla.novell.com/show_bug.cgi?id=652633
https://bugzilla.novell.com/show_bug.cgi?id=652633#c34
Dr. Werner Fink
https://bugzilla.novell.com/show_bug.cgi?id=652633
https://bugzilla.novell.com/show_bug.cgi?id=652633#c35
Kay Sievers
https://bugzilla.novell.com/show_bug.cgi?id=652633
https://bugzilla.novell.com/show_bug.cgi?id=652633#c38
Dr. Werner Fink
https://bugzilla.novell.com/show_bug.cgi?id=652633
https://bugzilla.novell.com/show_bug.cgi?id=652633#c40
--- Comment #40 from Dr. Werner Fink
https://bugzilla.novell.com/show_bug.cgi?id=652633
https://bugzilla.novell.com/show_bug.cgi?id=652633#c43
--- Comment #43 from Kay Sievers
I've submitted this patch to Base:System/systemd
As explained above, differences like that are not acceptable. Please let's fix the real problem and not the symptoms. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=652633
https://bugzilla.novell.com/show_bug.cgi?id=652633#c45
--- Comment #45 from Dr. Werner Fink
https://bugzilla.novell.com/show_bug.cgi?id=652633
https://bugzilla.novell.com/show_bug.cgi?id=652633#c46
--- Comment #46 from Kay Sievers
Beside this would you please respect private mode during discussions!
Oh, sorry. I couldn't think of any private things in here. Please respect that I will not reply to any of these issues if you use the private flag in the future, unless they contain private questions. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=652633
https://bugzilla.novell.com/show_bug.cgi?id=652633#c47
Dr. Werner Fink
participants (1)
-
bugzilla_noreply@novell.com