? pydb.diff
? pydb/.gdb.py.in.swp
? test/sigtest.py.in
? test/sigtestexample.py
Index: Makefile.am
===================================================================
RCS file: /cvsroot/bashdb/pydb/Makefile.am,v
retrieving revision 1.33
diff -u -r1.33 Makefile.am
--- Makefile.am	1 Aug 2006 14:46:19 -0000	1.33
+++ Makefile.am	11 Aug 2006 15:36:47 -0000
@@ -66,7 +66,7 @@
 	-rm $(top_builddir)/pydb/*.pyc
 
 test: check
-check: pydb/pydb.py pydb/gdb.py test/test.py test/pm.py
+check: pydb/pydb.py pydb/gdb.py test/test.py test/pm.py test/sigtest.py
 
 # 
 # For the executable, we make a symbolic link to the python program,
Index: configure.ac
===================================================================
RCS file: /cvsroot/bashdb/pydb/configure.ac,v
retrieving revision 1.35
diff -u -r1.35 configure.ac
--- configure.ac	29 Jul 2006 08:09:31 -0000	1.35
+++ configure.ac	11 Aug 2006 15:36:47 -0000
@@ -126,6 +126,7 @@
 AC_CONFIG_FILES([test/except.py],[chmod +x test/except.py])
 AC_CONFIG_FILES([test/pm.py],[chmod +x test/pm.py])
 AC_CONFIG_FILES([test/settrace.py],[chmod +x test/settrace.py])
+AC_CONFIG_FILES([test/sigtest.py], [chmod +x test/sigtest.py])
 AC_CONFIG_FILES([test/test.py],[chmod +x test/test.py])
 AC_CONFIG_FILES([test/trace.py],[chmod +x test/trace.py])
 
Index: pydb/gdb.py.in
===================================================================
RCS file: /cvsroot/bashdb/pydb/pydb/gdb.py.in,v
retrieving revision 1.51
diff -u -r1.51 gdb.py.in
--- pydb/gdb.py.in	8 Aug 2006 01:34:05 -0000	1.51
+++ pydb/gdb.py.in	11 Aug 2006 15:36:49 -0000
@@ -21,7 +21,7 @@
 from pydbcmd import Cmd
 from pydbbdb import Bdb
 
-from sighandler import SigHandler
+from sighandler import SigHandler, lookup_signame, lookup_signum
 
 class Restart(Exception):
     """Causes a debugger to be restarted for the debugged Python program."""
@@ -41,6 +41,7 @@
 
         # set up signal handling
         self._sig_handler = SigHandler(self)
+        self._reset_handler = None
 
         self.__init_info()
         self.__init_set()
@@ -118,6 +119,23 @@
         except ImportError:
             self.histfile = None
 
+    def trace_dispatch(self, frame, event, arg):
+        for sig in self._sig_handler._sigs.keys():
+            if self._sig_handler._sigs[sig][0] == True:
+                import signal
+                sig_num = lookup_signum(sig)
+                old_handler = signal.getsignal(sig_num)
+                if old_handler != self._sig_handler.handle:
+                    # save the program's signal handler
+                    self._sig_handler.old_handlers[sig_num] = old_handler
+                    
+                    # restore _our_ signal handler
+                    signal.signal(sig_num, self._sig_handler.handle)
+
+        Bdb.trace_dispatch(self, frame, event, arg)
+        return self.trace_dispatch
+
+
     def __adjust_frame(self, pos, absolute_pos):
         """Adjust stack frame by pos positions. If absolute_pos then
         pos is an absolute number. Otherwise it is a relative number.
Index: pydb/sighandler.py
===================================================================
RCS file: /cvsroot/bashdb/pydb/pydb/sighandler.py,v
retrieving revision 1.6
diff -u -r1.6 sighandler.py
--- pydb/sighandler.py	8 Aug 2006 02:04:25 -0000	1.6
+++ pydb/sighandler.py	11 Aug 2006 15:36:49 -0000
@@ -7,9 +7,8 @@
 #  - remove pychecker errors.
 #  - can remove signal handler altogether when
 #         ignore=True, print=False, pass=True
-#  - write real regression tests.
-#  
 #     
+#
 import signal
 
 def lookup_signame(num):
@@ -44,6 +43,8 @@
     def __init__(self, pydb): 
         self.pydb = pydb
         self._sigs = {}
+    
+        self.old_handlers = {}
 
         # set up signal handling for some known signals
         ignore= ['SIGALRM', 'SIGCHLD',  'SIGURG',  'SIGIO',      'SIGVTALRM'
@@ -59,7 +60,8 @@
                             self._sigs[sig] = (False, False, True)
                         else:
                             self._sigs[sig] = (True, True, True)
-                            signal.signal(num, self.handle)
+                            old_handler = signal.signal(num, self.handle)
+                            self.old_handlers[num] = old_handler
                 else:
                     # Make an entry in the _sig dict for these signals
                     # even though they cannot be ignored or caught.
@@ -93,9 +95,7 @@
             self.info_signal(['handle'])
             return
         args = arg.split()
-        try:
-            self._sigs[args[0]]
-        except KeyError:
+        if not self._sigs.has_key(args[0]):
             return
         if len(args) == 1:
             self.info_signal(args[0])
@@ -131,6 +131,7 @@
         old_attr = self._sigs[signame]
         st, pr, pa = change, old_attr[1], old_attr[2]
         if st:
+            # stop keyword implies print
             pr = True
         self._sigs[signame] = (st, pr, pa)
         return change
@@ -151,7 +152,7 @@
     def handle_ignore(self, signame, change):
         if not isinstance(change, bool):
             return
-        self.handle_pass(not change)
+        self.handle_pass(signame, not change)
         return change
 
     def handle_print(self, signame, change):
@@ -169,10 +170,17 @@
     def handle(self, signum, frame):
         """This method is called when a signal is received."""
         sig = lookup_signame(signum)
-        st, pa, pr = self._sigs[sig]
+        st, pr, pa = self._sigs[sig]
         if pr:
             self.pydb.msg('Program received signal %s' % sig)
         if st:
-            # XXX Rocky what's the best way to handle this? 
             self.pydb.use_rawinput = False
+            self.pydb.step_ignore = 1
             self.pydb.interaction(self.pydb.curframe, None)
+        if pa:
+            # pass the signal to the program by reinstating the old signal
+            # handler and send the signal to this process again
+            old_handler = self.old_handlers[signum]
+            signal.signal(signum, old_handler)
+            import os
+            os.kill(os.getpid(), signum)
Index: test/Makefile.am
===================================================================
RCS file: /cvsroot/bashdb/pydb/test/Makefile.am,v
retrieving revision 1.18
diff -u -r1.18 Makefile.am
--- test/Makefile.am	8 Aug 2006 01:34:06 -0000	1.18
+++ test/Makefile.am	11 Aug 2006 15:36:49 -0000
@@ -28,16 +28,16 @@
 	run.right       \
 	run2.cmd        \
 	run2.right      \
-	sighandler.cmd  \
-	sighandle.right \
+    sigtest.py      \
+    sigtestexample.py \
 	test.py         \
 	trace-2.5.right \
 	trace.py        \
 	trace.right
 
-TESTS = test.py pm.py trace.py
+TESTS = test.py pm.py trace.py sigtest.py
 
 EXTRA_DIST = $(check_DATA) except.py.in pm.py.in \
-	settrace.py.in test.py.in trace.py.in
+	settrace.py.in test.py.in trace.py.in sigtest.py.in
 
 test: check
