diff options
-rw-r--r-- | source3/lib/messages.c | 5 | ||||
-rw-r--r-- | source3/lib/signal.c | 8 | ||||
-rw-r--r-- | source3/lib/util_file.c | 5 |
3 files changed, 11 insertions, 7 deletions
diff --git a/source3/lib/messages.c b/source3/lib/messages.c index 3929f526dc..5d861b485c 100644 --- a/source3/lib/messages.c +++ b/source3/lib/messages.c @@ -475,6 +475,7 @@ BOOL message_named_mutex(char *name, unsigned int timeout) { TDB_DATA key; int ret; + void (*oldsig_handler)(int); if (!message_init()) return False; @@ -484,7 +485,7 @@ BOOL message_named_mutex(char *name, unsigned int timeout) if (timeout) { gotalarm = 0; - CatchSignal(SIGALRM, SIGNAL_CAST gotalarm_sig); + oldsig_handler = CatchSignal(SIGALRM, SIGNAL_CAST gotalarm_sig); alarm(timeout); } @@ -492,7 +493,7 @@ BOOL message_named_mutex(char *name, unsigned int timeout) if (timeout) { alarm(0); - CatchSignal(SIGALRM, SIGNAL_CAST SIG_IGN); + CatchSignal(SIGALRM, SIGNAL_CAST oldsig_handler); if (gotalarm) return False; } diff --git a/source3/lib/signal.c b/source3/lib/signal.c index 99f908235c..dceb3b53bc 100644 --- a/source3/lib/signal.c +++ b/source3/lib/signal.c @@ -96,10 +96,11 @@ void BlockSignals(BOOL block,int signum) 2) The signal should be blocked during handler execution. ********************************************************************/ -void CatchSignal(int signum,void (*handler)(int )) +void (*CatchSignal(int signum,void (*handler)(int )))(int) { #ifdef HAVE_SIGACTION struct sigaction act; + struct sigaction oldact; ZERO_STRUCT(act); @@ -113,10 +114,11 @@ void CatchSignal(int signum,void (*handler)(int )) #endif sigemptyset(&act.sa_mask); sigaddset(&act.sa_mask,signum); - sigaction(signum,&act,NULL); + sigaction(signum,&act,&oldact); + return oldact.sa_handler; #else /* !HAVE_SIGACTION */ /* FIXME: need to handle sigvec and systems with broken signal() */ - signal(signum, handler); + return signal(signum, handler); #endif } diff --git a/source3/lib/util_file.c b/source3/lib/util_file.c index fd3aeb99d9..883827a4f5 100644 --- a/source3/lib/util_file.c +++ b/source3/lib/util_file.c @@ -40,9 +40,10 @@ BOOL do_file_lock(int fd, int waitsecs, int type) { SMB_STRUCT_FLOCK lock; int ret; + void (*oldsig_handler)(int); gotalarm = 0; - CatchSignal(SIGALRM, SIGNAL_CAST gotalarm_sig); + oldsig_handler = CatchSignal(SIGALRM, SIGNAL_CAST gotalarm_sig); lock.l_type = type; lock.l_whence = SEEK_SET; @@ -54,7 +55,7 @@ BOOL do_file_lock(int fd, int waitsecs, int type) /* Note we must *NOT* use sys_fcntl here ! JRA */ ret = fcntl(fd, SMB_F_SETLKW, &lock); alarm(0); - CatchSignal(SIGALRM, SIGNAL_CAST SIG_IGN); + CatchSignal(SIGALRM, SIGNAL_CAST oldsig_handler); if (gotalarm) { DEBUG(0, ("do_file_lock: failed to %s file.\n", |