hishamhm / htop

htop is an interactive text-mode process viewer for Unix systems. It aims to be a better 'top'.
GNU General Public License v2.0
5.84k stars 581 forks source link

Fix signal handler #396

Open elfring opened 8 years ago

elfring commented 8 years ago

The functions "endwin" and "exit" do not belong to the list of async-signal-safe functions. I guess that a different program design will be needed for your function "CRT_handleSIGTERM".

GiedriusS commented 8 years ago

https://github.com/GiedriusS/htop/commit/232e24afe2fa8bc94bc4e7905c578c73e5576473 A quick and dirty fix would look like this. Because that new member is only useful in one place and have nothing to do with screens maybe the quit variable should just have external linkage and be set to true from the signal handler. What does @hishamhm think?

hishamhm commented 8 years ago

@GiedriusS thanks for the suggestion!

This looks interesting. I'd rather use a separate global for this purpose rather than exposing src (this might open Pandora's box for other uses of this variable elsewhere).

GiedriusS commented 8 years ago

Currently have this: https://github.com/GiedriusS/htop/commit/db8d21180ed16d0c38232cc36220ff458ff24df6 I have one specific problem with this. On some systems getch() may not be interrupted by a signal so the user may still see htop until getch() returns (PORTABILITY section in man getch). Does anyone have an idea how to solve this or to make it "correct"? Perhaps this is acceptable? Also, SIGSEGV platform specific signal handlers need to be fixed too.

hishamhm commented 8 years ago

@GiedriusS please don't get caught up in minutiae. htop requires ncurses. XSI Curses portability issues are of no concern. It's a fun game to try to be super-portable but I'm concerned only with practical issues — crashes or failures affecting real users, not complying to specifications.