Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 336289 - sys-process/procps: top keeps running when from su and terminal is closed
Summary: sys-process/procps: top keeps running when from su and terminal is closed
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: AMD64 Linux
: High normal
Assignee: Gentoo's Team for Core System packages
URL: http://sourceforge.net/mailarchive/fo...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-06 22:01 UTC by Ambroz Bizjak
Modified: 2012-05-17 04:05 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
backtraces (top-backtrace.txt,9.40 KB, text/plain)
2010-09-07 17:49 UTC, Ambroz Bizjak
Details
paludis --info sys-process/procps (info.txt,13.25 KB, text/plain)
2010-09-07 17:50 UTC, Ambroz Bizjak
Details
Patch to fix the issue (0001-Enable-the-EOF-check-to-fix-Gentoo-Bug-336289.patch,1.30 KB, patch)
2010-09-22 08:06 UTC, Michał Górny
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ambroz Bizjak 2010-09-06 22:01:00 UTC
When top is running in a terminal emulator (Konsole, xterm) from within "su", and the terminal is closed, it keeps running and hogs the CPU.

Reproducible: Always

Steps to Reproduce:
1. Open a terminal emulator (as a user) in a desktop session. I've tested Konsole and xterm from within KDE 4.5.1.
2. su
3. top
4. while top is running, close the terminal window

Actual Results:  
top keeps running, and eats all CPU.
pstree shows:
init─┬
     ...
     ├─su───bash───top


Expected Results:  
top should exit when terminal is closed.
Comment 1 Jeroen Roovers (RETIRED) gentoo-dev 2010-09-07 16:51:39 UTC
I can't reproduce that with x11-terms/rxvt-unicode under x11-wm/musca. I also doubt it's a problem with sys-process/procps. Please post your `emerge --info'. A gdb backtrace of the top process in question would also be nice.
Comment 2 Ambroz Bizjak 2010-09-07 17:49:42 UTC
Created attachment 246374 [details]
backtraces

I also cannot reproduce it x11-terms/rxvt-unicode. I am sure you will be able to with Konsole and xterm, because others have too.
I am attaching three backtraces
Comment 3 Ambroz Bizjak 2010-09-07 17:50:23 UTC
Created attachment 246376 [details]
paludis --info sys-process/procps
Comment 4 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2010-09-21 17:26:42 UTC
I am able to reproduce that with x11-terms/terminal and xterm. Not sure, however, how could we fix this...

I guess the terminal simply is unable to send SIGHUP to 'su' as it is setuid. This is a very general issue, and it seems not really related to a particular terminal. On the other hand, I can't reproduce it on a login shell...
Comment 5 Ambroz Bizjak 2010-09-21 23:28:11 UTC
(In reply to comment #4)
> I guess the terminal simply is unable to send SIGHUP to 'su' as it is setuid.
This is not true; the bug can be reproduced even if xterm is running as root (I believe the terminal does not need to send SIGHUP to the program; it is sent by the kernel when the controlling end of the pseudo-terminal is closed).
IMO, this is an issue with top and not any terminal, since top is the process caught in an infinite loop. Even if it's waiting for something, busy waiting is the wrong thing to do.
Comment 6 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2010-09-22 07:55:11 UTC
I've retried this with gdb-attached top and it doesn't receive SIGHUP at all. Neither does su or bash running it.
Comment 7 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2010-09-22 08:06:11 UTC
Created attachment 248336 [details, diff]
Patch to fix the issue

Ah, got it. Someone smart wanted to optimize the code too much.
Comment 8 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2010-09-22 18:15:41 UTC
I've reported the issue upstream. Hope sourceforge does deliver messages better than it archives them.
Comment 9 Jekyll Wu 2012-04-14 03:00:32 UTC
Seems fixed using sys-process/procps-3.3.2_p2-r1