From: Darren S. <ds...@us...> - 2006-05-29 23:57:30
|
Update of /cvsroot/xine/gnome-xine/src In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv1744/src Modified Files: main.c Log Message: Watchdog timer. Alarm triggers abort() if the watchdog isn't called for 30s. Index: main.c =================================================================== RCS file: /cvsroot/xine/gnome-xine/src/main.c,v retrieving revision 1.166 retrieving revision 1.167 diff -u -r1.166 -r1.167 --- main.c 3 May 2006 22:33:52 -0000 1.166 +++ main.c 29 May 2006 23:57:27 -0000 1.167 @@ -26,6 +26,7 @@ #include "globals.h" #include <string.h> +#include <signal.h> #include <errno.h> #include <sys/types.h> #include <sys/stat.h> @@ -220,6 +221,25 @@ return FALSE; } +#ifdef WITH_WATCHDOG +/* Watchdog functions */ + +static gboolean watchdog_timer_reset (gpointer data) +{ + alarm (30); + return TRUE; +} + +static void watchdog_timeout (int sig) +{ + /* if this happens, we have a problem... */ + g_printerr (_("gxine: killed by watchdog bite\n")); + abort (); +} +#endif + +/* Main */ + int main(int argc, char* argv[]) { gboolean enqueue, autoplay, fullscreen; @@ -414,6 +434,7 @@ * just pass on the files to play */ + sched_yield (); gxine_try_remote (argc, argv, enqueue, autoplay); /* start using X... */ @@ -438,6 +459,15 @@ g_free (fname); } +#ifdef WITH_WATCHDOG + /* + * Watchdog + */ + + g_timeout_add (2500, watchdog_timer_reset, NULL); /* <- will set the alarm */ + signal (SIGALRM, watchdog_timeout); +#endif + /* * init xine, set up script engine */ |