comparison console/libgnt/gntmain.c @ 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 665b814f8fd7
children 39b0124a455d
comparison
equal deleted inserted replaced
14380:4badb7289e31 14381:3bfea4c4ce33
19 #include <locale.h> 19 #include <locale.h>
20 #include <unistd.h> 20 #include <unistd.h>
21 #include <signal.h> 21 #include <signal.h>
22 #include <string.h> 22 #include <string.h>
23 #include <ctype.h> 23 #include <ctype.h>
24 #include <errno.h>
25
26 #include <sys/types.h>
27 #include <sys/wait.h>
24 28
25 /** 29 /**
26 * Notes: Interesting functions to look at: 30 * Notes: Interesting functions to look at:
27 * scr_dump, scr_init, scr_restore: for workspaces 31 * scr_dump, scr_init, scr_restore: for workspaces
28 * 32 *
880 draw_taskbar(TRUE); 884 draw_taskbar(TRUE);
881 885
882 return FALSE; 886 return FALSE;
883 } 887 }
884 888
889 /* Xerox */
890 static void
891 clean_pid(void)
892 {
893 int status;
894 pid_t pid;
895
896 do {
897 pid = waitpid(-1, &status, WNOHANG);
898 } while (pid != 0 && pid != (pid_t)-1);
899
900 if ((pid == (pid_t) - 1) && (errno != ECHILD)) {
901 char errmsg[BUFSIZ];
902 snprintf(errmsg, BUFSIZ, "Warning: waitpid() returned %d", pid);
903 perror(errmsg);
904 }
905 }
906
907 static void
908 sighandler(int sig)
909 {
910 switch (sig) {
885 #ifdef SIGWINCH 911 #ifdef SIGWINCH
886 static void 912 case SIGWINCH:
887 sighandler(int sig)
888 {
889 if (sig == SIGWINCH)
890 {
891 werase(stdscr); 913 werase(stdscr);
892 wrefresh(stdscr); 914 wrefresh(stdscr);
893
894 g_idle_add(refresh_screen, NULL); 915 g_idle_add(refresh_screen, NULL);
895 } 916 signal(SIGWINCH, sighandler);
896 917 break;
897 signal(SIGWINCH, sighandler);
898 }
899 #endif 918 #endif
919 case SIGCHLD:
920 clean_pid();
921 signal(SIGCHLD, sighandler);
922 break;
923 }
924 }
900 925
901 static void 926 static void
902 init_wm() 927 init_wm()
903 { 928 {
904 const char *name = gnt_style_get(GNT_STYLE_WM); 929 const char *name = gnt_style_get(GNT_STYLE_WM);
908 return; 933 return;
909 934
910 handle = g_module_open(name, G_MODULE_BIND_LAZY); 935 handle = g_module_open(name, G_MODULE_BIND_LAZY);
911 if (handle) { 936 if (handle) {
912 gboolean (*init)(GntWM *); 937 gboolean (*init)(GntWM *);
913 if (g_module_symbol(handle, "gntwm_init", &init)) { 938 if (g_module_symbol(handle, "gntwm_init", (gpointer)&init)) {
914 init(&wm); 939 init(&wm);
915 } 940 }
916 } 941 }
917 } 942 }
918 943
981 wrefresh(stdscr); 1006 wrefresh(stdscr);
982 1007
983 #ifdef SIGWINCH 1008 #ifdef SIGWINCH
984 signal(SIGWINCH, sighandler); 1009 signal(SIGWINCH, sighandler);
985 #endif 1010 #endif
1011 signal(SIGCHLD, sighandler);
986 1012
987 g_type_init(); 1013 g_type_init();
988 1014
989 init_wm(); 1015 init_wm();
990 } 1016 }