# HG changeset patch # User Sadrul Habib Chowdhury # Date 1156957784 0 # Node ID 3bfea4c4ce33e225ee389c6bf862e04fa03bfe57 # Parent 4badb7289e3193bede912444cd1c8c2408acddca [gaim-migrate @ 17087] Do stuff with SIGCHLD committer: Tailor Script diff -r 4badb7289e31 -r 3bfea4c4ce33 console/libgnt/gntmain.c --- a/console/libgnt/gntmain.c Wed Aug 30 06:26:40 2006 +0000 +++ b/console/libgnt/gntmain.c Wed Aug 30 17:09:44 2006 +0000 @@ -21,6 +21,10 @@ #include #include #include +#include + +#include +#include /** * Notes: Interesting functions to look at: @@ -882,21 +886,42 @@ return FALSE; } -#ifdef SIGWINCH +/* Xerox */ +static void +clean_pid(void) +{ + int status; + pid_t pid; + + do { + pid = waitpid(-1, &status, WNOHANG); + } while (pid != 0 && pid != (pid_t)-1); + + if ((pid == (pid_t) - 1) && (errno != ECHILD)) { + char errmsg[BUFSIZ]; + snprintf(errmsg, BUFSIZ, "Warning: waitpid() returned %d", pid); + perror(errmsg); + } +} + static void sighandler(int sig) { - if (sig == SIGWINCH) - { + switch (sig) { +#ifdef SIGWINCH + case SIGWINCH: werase(stdscr); wrefresh(stdscr); - g_idle_add(refresh_screen, NULL); + signal(SIGWINCH, sighandler); + break; +#endif + case SIGCHLD: + clean_pid(); + signal(SIGCHLD, sighandler); + break; } - - signal(SIGWINCH, sighandler); } -#endif static void init_wm() @@ -910,7 +935,7 @@ handle = g_module_open(name, G_MODULE_BIND_LAZY); if (handle) { gboolean (*init)(GntWM *); - if (g_module_symbol(handle, "gntwm_init", &init)) { + if (g_module_symbol(handle, "gntwm_init", (gpointer)&init)) { init(&wm); } } @@ -983,6 +1008,7 @@ #ifdef SIGWINCH signal(SIGWINCH, sighandler); #endif + signal(SIGCHLD, sighandler); g_type_init();