diff src/protocol.c @ 164:94f2e5607772 noffle

[svn] * src/client.c,src/protocol.c,src/util.h,src/util.c: Common up repeated signal handler setting code into Utl_installSignalHandler. * src/client.c: Ensure Client_retrieveArt always exits with the global lock held. Previously it would be held on error, not held if OK.
author bears
date Thu, 25 Jan 2001 11:00:03 +0000
parents cb799054bd61
children fed1334d766b
line wrap: on
line diff
--- a/src/protocol.c	Sun Jan 07 11:15:58 2001 +0000
+++ b/src/protocol.c	Thu Jan 25 11:00:03 2001 +0000
@@ -1,7 +1,7 @@
 /*
   protocol.c
 
-  $Id: protocol.c 228 2000-10-26 21:29:55Z bears $
+  $Id: protocol.c 248 2001-01-25 11:00:03Z bears $
 */
 
 #if HAVE_CONFIG_H
@@ -33,23 +33,6 @@
     return;
 }
 
-static sig_t
-installSignalHandler( int sig, sig_t handler )
-{
-    struct sigaction act, oldAct;
-
-    act.sa_handler = handler;
-    sigemptyset( &act.sa_mask );
-    act.sa_flags = 0;
-    if ( sig == SIGALRM )
-        act.sa_flags |= SA_INTERRUPT;
-    else
-        act.sa_flags |= SA_RESTART;
-    if ( sigaction( sig, &act, &oldAct ) < 0 )
-        return SIG_ERR;
-    return oldAct.sa_handler;
-}
-
 Bool
 Prt_getLn( Str line, FILE *f, int timeoutSeconds )
 {
@@ -59,7 +42,7 @@
 
     if ( timeoutSeconds >= 0 )
     {
-        oldHandler = installSignalHandler( SIGALRM, readAlarm );
+        oldHandler = Utl_installSignalHandler( SIGALRM, readAlarm );
         if ( oldHandler == SIG_ERR )
         {
             Log_err( "Prt_getLn: signal failed." );
@@ -76,7 +59,7 @@
     if ( timeoutSeconds >= 0 )
     {
         alarm( 0 );
-        installSignalHandler( SIGALRM, oldHandler );
+        Utl_installSignalHandler( SIGALRM, oldHandler );
     }
     if ( ret == NULL )
         return FALSE;