Revision: 7883
          http://playerstage.svn.sourceforge.net/playerstage/?rev=7883&view=rev
Author:   thjc
Date:     2009-06-23 15:12:13 +0000 (Tue, 23 Jun 2009)

Log Message:
-----------
added handler for SIGTERM to player
also made player die immediately on a second signal (i.e. ctrl+c twice)
change from using signal to more standard sigaction to set signal handlers

Modified Paths:
--------------
    code/player/trunk/server/server.cc

Modified: code/player/trunk/server/server.cc
===================================================================
--- code/player/trunk/server/server.cc  2009-06-23 15:11:38 UTC (rev 7882)
+++ code/player/trunk/server/server.cc  2009-06-23 15:12:13 UTC (rev 7883)
@@ -141,18 +141,35 @@
   char* cfgfilename;
   char * logfileName = NULL;
 
+#ifdef WIN32
   if(signal(SIGINT, Quit) == SIG_ERR)
   {
     PLAYER_ERROR1("signal() failed: %s", strerror(errno));
     exit(-1);
   }
-
-#if !defined (WIN32)
-  if(signal(SIGPIPE, SIG_IGN) == SIG_ERR)
+#else
+  struct sigaction quit_action = {{0}};
+  quit_action.sa_handler = Quit;
+  sigemptyset (&quit_action.sa_mask);
+  quit_action.sa_flags = SA_RESETHAND;
+  struct sigaction ignore_action = {{0}};
+  ignore_action.sa_handler = SIG_IGN;
+  sigemptyset (&ignore_action.sa_mask);
+  if(sigaction(SIGINT, &quit_action, NULL) != 0)
   {
     PLAYER_ERROR1("signal() failed: %s", strerror(errno));
     exit(-1);
   }
+  if(sigaction(SIGTERM, &quit_action, NULL) != 0)
+  {
+    PLAYER_ERROR1("signal() failed: %s", strerror(errno));
+    exit(-1);
+  }
+  if(sigaction(SIGPIPE, &ignore_action, NULL) != 0)
+  {
+    PLAYER_ERROR1("signal() failed: %s", strerror(errno));
+    exit(-1);
+  }
 #endif
 
   player_globals_init();


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to