Bug#354255: procps: top exits with non zero exit code in normal cases
Hi, I'm not sure I can follow you here: Alternatively, you can call bye_bye() with the dont_care_sig parameter, but be aware that there are a few functions that take the dont_care_sig parameter, but throw that value away. The other installed signal-handlers suspend() and wins_resize_sighandler() are throwing it away because their action doesn't depend on the exact signal delivered - but end_pgm() should certainly base the exit code that it's going to pass on to bye_bye() on the incoming parameter. Patch attached. Regards, Jan #! /bin/sh /usr/share/dpatch/dpatch-run ## 45_top_exitcode.dpatch by [EMAIL PROTECTED] ## ## DP: Make top exit with return code 0 if the program was closed ## DP: cleanly ('q' or end of iteration loop). @DPATCH@ --- procps-3.2.7/top.cO 2007-08-06 15:57:04.0 +0200 +++ procps-3.2.7/top.c 2007-08-06 16:04:07.0 +0200 @@ -402,14 +402,13 @@ /* - * Normal end of execution. + * Normal end of execution. Exit with 1 if signaled, else 0. * catches: *SIGALRM, SIGHUP, SIGINT, SIGPIPE, SIGQUIT and SIGTERM */ -static void end_pgm (int dont_care_sig) NORETURN; -static void end_pgm (int dont_care_sig) +static void end_pgm (int sig) NORETURN; +static void end_pgm (int sig) { - (void)dont_care_sig; - bye_bye(stdout, 1, NULL); + bye_bye(stdout, !!sig, NULL); } signature.asc Description: Digital signature
Bug#354255: procps: top exits with non zero exit code in normal cases - patch attached
package procps tags 354255 + patch thanks Hi, after a normal quit, top returns with exit code 1 which indicates an error. Bye, Jörg. In the file top.c, there is a function called do_key(). If 'q' is pressed to quit the program, end_pgm(0) is called. Here is the function: /* * Normal end of execution. * catches: *SIGALRM, SIGHUP, SIGINT, SIGPIPE, SIGQUIT and SIGTERM */ static void end_pgm (int dont_care_sig) NORETURN; static void end_pgm (int dont_care_sig) { (void)dont_care_sig; bye_bye(stdout, 1, NULL); } The parameter '0' is never used in this function, instead, a function is called - bye_bye(stdout, 1, NULL). In bye_bye(), exit() is called with the second parameter, thus /usr/bin/top always exits with the exit code '1' if you type 'q'. If you grep for bye_bye, you will see it called with parameters (stderr, 1, NULL). I think the call in end_pgm() should be bye_bye(stdout, 0, NULL), as the comments for end_pgm() reads Normal end of execution. Alternatively, you can call bye_bye() with the dont_care_sig parameter, but be aware that there are a few functions that take the dont_care_sig parameter, but throw that value away. Patch attached. --- top.c 2006-06-24 23:41:48.0 -0700 +++ topFIX.c 2007-04-29 19:34:44.0 -0700 @@ -409,7 +409,7 @@ static void end_pgm (int dont_care_sig) { (void)dont_care_sig; - bye_bye(stdout, 1, NULL); + bye_bye(stdout, 0, NULL); }
Bug#354255: procps: top exits with non zero exit code in normal cases
Package: procps Version: 1:3.2.6-2 Severity: normal Hi, after a normal quit, top returns with exit code 1 which indicates an error. Bye, Jörg. -- System Information: Debian Release: unstable/experimental APT prefers unstable APT policy: (990, 'unstable'), (1, 'experimental') Architecture: powerpc (ppc) Shell: /bin/sh linked to /bin/dash Kernel: Linux 2.6.15.4 Locale: LANG=de_DE, LC_CTYPE=de_DE (charmap=ISO-8859-1) Versions of packages procps depends on: ii libc6 2.3.6-1GNU C Library: Shared libraries an ii libncurses5 5.5-1 Shared libraries for terminal hand Versions of packages procps recommends: ii psmisc22.1-1 Utilities that use the proc filesy -- no debconf information pgpy3taQKKuE9.pgp Description: PGP signature