Mercurial > pidgin
changeset 14381:3bfea4c4ce33
[gaim-migrate @ 17087]
Do stuff with SIGCHLD
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Wed, 30 Aug 2006 17:09:44 +0000 |
parents | 4badb7289e31 |
children | 7b590ba06651 |
files | console/libgnt/gntmain.c |
diffstat | 1 files changed, 34 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- 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 <signal.h> #include <string.h> #include <ctype.h> +#include <errno.h> + +#include <sys/types.h> +#include <sys/wait.h> /** * 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();