Mercurial > noffle
diff src/util.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 | 3c71e28c8eef |
children | fed1334d766b |
line wrap: on
line diff
--- a/src/util.c Sun Jan 07 11:15:58 2001 +0000 +++ b/src/util.c Thu Jan 25 11:00:03 2001 +0000 @@ -1,7 +1,7 @@ /* util.c - $Id: util.c 183 2000-07-25 12:14:54Z bears $ + $Id: util.c 248 2001-01-25 11:00:03Z bears $ */ #if HAVE_CONFIG_H @@ -462,6 +462,21 @@ memcpy( *dst, src, (size_t)len + 1 ); } +sig_t +Utl_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_RESTART; + if ( sigaction( sig, &act, &oldAct ) < 0 ) + return SIG_ERR; + return oldAct.sa_handler; +} + #if defined(UTIL_TEST) /* Test code borrowed from wildmat.c. Yep, still uses gets(). */