@@ -2744,6 +2744,8 @@ def test_toy_build_lock(self):
27442744 # also test use of --ignore-locks
27452745 self .test_toy_build (extra_args = extra_args + ['--ignore-locks' ], verify = True , raise_error = True )
27462746
2747+ orig_sigalrm_handler = signal .getsignal (signal .SIGALRM )
2748+
27472749 # define a context manager that remove a lock after a while, so we can check the use of --wait-for-lock
27482750 class remove_lock_after (object ):
27492751 def __init__ (self , seconds , lock_fp ):
@@ -2759,7 +2761,7 @@ def __enter__(self):
27592761
27602762 def __exit__ (self , type , value , traceback ):
27612763 # clean up SIGALRM signal handler, and cancel scheduled alarm
2762- signal .signal (signal .SIGALRM , signal . SIG_DFL )
2764+ signal .signal (signal .SIGALRM , orig_sigalrm_handler )
27632765 signal .alarm (0 )
27642766
27652767 # wait for lock to be removed, with 1 second interval of checking;
@@ -2858,6 +2860,8 @@ def test_toy_lock_cleanup_signals(self):
28582860 locks_dir = os .path .join (self .test_installpath , 'software' , '.locks' )
28592861 self .assertFalse (os .path .exists (locks_dir ))
28602862
2863+ orig_sigalrm_handler = signal .getsignal (signal .SIGALRM )
2864+
28612865 # context manager which stops the function being called with the specified signal
28622866 class wait_and_signal (object ):
28632867 def __init__ (self , seconds , signum ):
@@ -2873,7 +2877,7 @@ def __enter__(self):
28732877
28742878 def __exit__ (self , type , value , traceback ):
28752879 # clean up SIGALRM signal handler, and cancel scheduled alarm
2876- signal .signal (signal .SIGALRM , signal . SIG_DFL )
2880+ signal .signal (signal .SIGALRM , orig_sigalrm_handler )
28772881 signal .alarm (0 )
28782882
28792883 # add extra sleep command to ensure session takes long enough
0 commit comments