[Aptitude-svn-commit] r3714 - in branches/aptitude-0.3/aptitude: . src src/vscreen

Daniel Burrows dburrows at costa.debian.org
Sat Aug 6 15:05:41 UTC 2005


Author: dburrows
Date: Sat Aug  6 15:05:38 2005
New Revision: 3714

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/pkg_ver_item.cc
   branches/aptitude-0.3/aptitude/src/vscreen/vscreen.cc
   branches/aptitude-0.3/aptitude/src/vscreen/vscreen.h
   branches/aptitude-0.3/aptitude/src/vscreen/vscreen_widget.h
Log:
Explicitly reset SIGCONT and SIGTSTP to SIG_DFL in vscreen_suspend,
restore them in vscreen_resume.

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Sat Aug  6 15:05:38 2005
@@ -1,5 +1,12 @@
 2005-08-05  Daniel Burrows  <dburrows at debian.org>
 
+	* src/vscreen/vscreen.cc, src/vscreen/vscreen.h, src/vscreen/vscreen_widget.h:
+
+	  Explicitly reset SIGCONT and SIGTSTP to SIG_DFL in
+	  vscreen_suspend and restore them in vscreen_resume.  If you
+	  don't want to reset the signals for some reason, you can use
+	  vscreen_suspend_without_signals().  (Closes: #137311, #169479)
+
 	* src/generic/aptcache.cc:
 
 	  Always save the version to be installed, so long as it's a

Modified: branches/aptitude-0.3/aptitude/src/pkg_ver_item.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/pkg_ver_item.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/pkg_ver_item.cc	Sat Aug  6 15:05:38 2005
@@ -45,6 +45,8 @@
 #include <apt-pkg/policy.h>
 #include <apt-pkg/strutl.h>
 
+#include <signal.h>
+
 using namespace std;
 
 class pkg_ver_columnizer:public pkg_item::pkg_columnizer
@@ -714,14 +716,32 @@
       // Try to report a bug on the package.  (ew quoting ew)
       string cmd=string("reportbug '")+version.ParentPkg().Name()+"' -V '"+version.VerStr()+"'";
 
+
+      struct sigaction oldact;
+      struct sigaction act;
+      act.sa_handler = SIG_DFL;
+      act.sa_sigaction = 0;
+      sigemptyset(&act.sa_mask);
+      act.sa_flags = 0;
+      act.sa_restorer = 0;
+
+      sigaction(SIGCONT, &act, &oldact);
+
       vscreen_suspend();
 
       apt_cache_file->ReleaseLock();
 
       printf(_("Reporting a bug in %s:\n"), version.ParentPkg().Name());
 
+
+
+
       system(cmd.c_str());
 
+      sigaction(SIGCONT, &oldact, NULL);
+
+
+
       vscreen_resume();
 
       apt_reload_cache(gen_progress_bar(), true);

Modified: branches/aptitude-0.3/aptitude/src/vscreen/vscreen.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vscreen.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vscreen.cc	Sat Aug  6 15:05:38 2005
@@ -63,6 +63,9 @@
 bool curses_avail=false;
 bool should_exit=false;
 
+static bool suspended_with_signals = false;
+static struct sigaction oldsigcont, oldsigtstp;
+
 // Used to queue and merge update requests
 static bool needs_layout=false;
 static bool needs_update=false;
@@ -642,7 +645,7 @@
   should_exit=1;
 }
 
-void vscreen_suspend()
+void vscreen_suspend_without_signals()
 {
   if(toplevel)
     toplevel->set_owner_window(NULL, 0, 0, 0, 0);
@@ -650,8 +653,32 @@
   curses_avail=false;
 }
 
+void vscreen_suspend()
+{
+  suspended_with_signals = true;
+
+  struct sigaction act;
+  act.sa_handler = SIG_IGN;
+  act.sa_sigaction = 0;
+  sigemptyset(&act.sa_mask);
+  act.sa_flags = 0;
+  act.sa_restorer = 0;
+
+  sigaction(SIGCONT, &act, &oldsigcont);
+  sigaction(SIGTSTP, &act, &oldsigtstp);
+
+  vscreen_suspend_without_signals();
+}
+
 void vscreen_resume()
 {
+  if(suspended_with_signals)
+    {
+      sigaction(SIGCONT, &oldsigcont, NULL);
+      sigaction(SIGTSTP, &oldsigtstp, NULL);
+      suspended_with_signals = false;
+    }
+
   curses_avail=true;
   if(toplevel)
     {

Modified: branches/aptitude-0.3/aptitude/src/vscreen/vscreen.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vscreen.h	(original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vscreen.h	Sat Aug  6 15:05:38 2005
@@ -1,6 +1,6 @@
 // vscreen.h                          -*-c++-*-
 //
-//  Copyright 2000 Daniel Burrows
+//  Copyright 2000, 2005 Daniel Burrows
 //
 //  This program is free software; you can redistribute it and/or modify
 //  it under the terms of the GNU General Public License as published by
@@ -77,9 +77,22 @@
 void vscreen_updatecursor();
 // Just updates the cursor status
 
+/** Hides all widgets and suspends Curses operation until
+ *  vscreen_resume() is called.  In addition, sets SIGCONT and SIGTSTP
+ *  to SIG_DFL (appropriate if you'll be running subprocesses);
+ *  vscreen_resume() will restore these handlers.
+ */
 void vscreen_suspend();
-// Hides all virtual screens and suspends Curses operation until vscreen_resume
-// is called.
+
+/** Hides all widgets and suspends Curses operation until
+ *  vscreen_resume() is called, but does NOT reset the SIGCONT and
+ *  SIGTSTP handlers.
+ */
+void vscreen_suspend_without_signals();
+
+/** Returns to Curses mode after a vscreen_suspend*, restoring any
+ *  signal handlers that were modified by the suspend routine.
+ */
 void vscreen_resume();
 
 int vscreen_addtimeout(const sigc::slot0<void> &slot, int msecs);

Modified: branches/aptitude-0.3/aptitude/src/vscreen/vscreen_widget.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vscreen_widget.h	(original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vscreen_widget.h	Sat Aug  6 15:05:38 2005
@@ -62,7 +62,7 @@
   friend void vscreen_mainloop(int);
   friend void vscreen_redraw();
   friend void vscreen_settoplevel(vscreen_widget *);
-  friend void vscreen_suspend();
+  friend void vscreen_suspend_without_signals();
   friend void vscreen_resume();
   friend void vscreen_updatecursornow();
   friend void vscreen_handleresize();



More information about the Aptitude-svn-commit mailing list