changeset 163:a8f7dc0a56cb

[/trunk] Changeset 175 by mikael * Catch SIGCHLD signal (children for external commands).
author mikael
date Mon, 02 May 2005 14:18:55 +0000
parents 43cef0f5339d
children faf534be8ff0
files mcabber/src/main.c
diffstat 1 files changed, 14 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/src/main.c	Mon May 02 12:30:13 2005 +0000
+++ b/mcabber/src/main.c	Mon May 02 14:18:55 2005 +0000
@@ -6,6 +6,8 @@
 #include <signal.h>
 #include <termios.h>
 #include <getopt.h>
+#include <sys/types.h>
+#include <sys/wait.h>
 
 #include "jabglue.h"
 #include "screen.h"
@@ -13,13 +15,23 @@
 #include "roster.h"
 #include "commands.h"
 #include "histolog.h"
+#include "hooks.h"
 #include "utils.h"
 #include "harddefines.h"
 
 
 void sig_handler(int signum)
 {
-  if (signum == SIGTERM) {
+  if (signum == SIGCHLD) {
+    int status;
+    pid_t pid;
+    do {
+      pid = waitpid (WAIT_ANY, &status, WNOHANG);
+    } while (pid > 0);
+    if (pid < 0)
+      ut_WriteLog("Error in waitpid: errno=%d\n", errno);
+    signal(SIGCHLD, sig_handler);
+  } else if (signum == SIGTERM) {
     // bud_TerminateBuddies();
     scr_TerminateCurses();
     jb_disconnect();
@@ -90,7 +102,7 @@
 
   ut_WriteLog("Setting signals handlers...\n");
   signal(SIGTERM, sig_handler);
-  signal(SIGALRM, sig_handler);
+  signal(SIGCHLD, sig_handler);
 
   sprintf(configFile, "%s/.mcabberrc", getenv("HOME"));