[procps] PS does ignore SIGPIPE which breaks batch jobs

  • From: "Dr. Werner Fink" <werner@xxxxxxx>
  • To: procps@xxxxxxxxxxxxx
  • Date: Wed, 20 Apr 2011 15:16:17 +0200

Hi

I've a bugzilla report here that complain that the ps command
ignores SIGPIPE which breaks the (HA)moniter script of the
customer, I supose the change

diff -ur procps-3.2.6.orig/ps/display.c procps-3.2.6/ps/display.c
--- procps-3.2.6.orig/ps/display.c  2011-03-22 09:33:52.357999000 +0100
+++ procps-3.2.6/ps/display.c   2011-03-22 09:35:09.598837000 +0100
@@ -41,7 +41,11 @@
 
 /* just reports a crash */
 static void signal_handler(int signo){
-  if(signo==SIGPIPE) _exit(0);  /* "ps | head" will cause this */
+  if(signo==SIGPIPE){
+    signal(signo, SIG_DFL);
+    kill(getpid(), signo);
+    return;
+  }
   /* fprintf() is not reentrant, but we _exit() anyway */
   fprintf(stderr,
     "\n\n"

... that will raise the signal and this change does help.

   Werner

-- 
Debian, Fedora and openSUSE fork of procps - http://gitorious.org/procps/

Other related posts: