From: <sa...@us...> - 2006-08-30 17:09:52
|
Revision: 17087 http://svn.sourceforge.net/gaim/?rev=17087&view=rev Author: sadrul Date: 2006-08-30 10:09:44 -0700 (Wed, 30 Aug 2006) Log Message: ----------- Do stuff with SIGCHLD Modified Paths: -------------- trunk/console/libgnt/gntmain.c Modified: trunk/console/libgnt/gntmain.c =================================================================== --- trunk/console/libgnt/gntmain.c 2006-08-30 06:26:40 UTC (rev 17086) +++ trunk/console/libgnt/gntmain.c 2006-08-30 17:09:44 UTC (rev 17087) @@ -21,7 +21,11 @@ #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: * scr_dump, scr_init, scr_restore: for workspaces @@ -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(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |