public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
* [SCM]  master: Ctrl-C handling for fhpd.
@ 2008-03-07 20:33 tthomas
  0 siblings, 0 replies; only message in thread
From: tthomas @ 2008-03-07 20:33 UTC (permalink / raw)
  To: frysk-cvs

The branch, master has been updated
       via  72d3c65c57aab4c51e312cc4ccb3191092daa5f1 (commit)
      from  e337778c9c77d8fbd6bd36f695ea50e8d9a3cd4f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 72d3c65c57aab4c51e312cc4ccb3191092daa5f1
Author: Teresa Thomas <tthomas@redhat.com>
Date:   Fri Mar 7 14:29:50 2008 -0500

    Ctrl-C handling for fhpd.
    
    frysk-core/frysk/hpd/ChangeLog:
    2008-03-07  Teresa Thomas  <tthomas@redhat.com>
    .
    	* CLI.java (SteppingObserver.getMonitor): Add events to
    	handle SIGINT.
    	* ShellCommand.java (interpretCommand): Ditto.
    	* SigIntHandler.java: New.
    
    frysk-core/frysk/bindir/ChangeLog:
    2008-03-07  Teresa Thomas  <tthomas@redhat.com>
    
    	* fhpd.java (main): Add event to handle SIGINT.

-----------------------------------------------------------------------

Summary of changes:
 frysk-core/frysk/bindir/ChangeLog                  |    4 +++
 frysk-core/frysk/bindir/fhpd.java                  |    3 ++
 frysk-core/frysk/hpd/CLI.java                      |   24 ++++++++++++++++-
 frysk-core/frysk/hpd/ChangeLog                     |    7 +++++
 frysk-core/frysk/hpd/ShellCommand.java             |   15 ++++++++++-
 .../{TestShellCommand.java => SigIntHandler.java}  |   28 ++++++++++++-------
 6 files changed, 69 insertions(+), 12 deletions(-)
 copy frysk-core/frysk/hpd/{TestShellCommand.java => SigIntHandler.java} (80%)

First 500 lines of diff:
diff --git a/frysk-core/frysk/bindir/ChangeLog b/frysk-core/frysk/bindir/ChangeLog
index b82ef23..a399be4 100644
--- a/frysk-core/frysk/bindir/ChangeLog
+++ b/frysk-core/frysk/bindir/ChangeLog
@@ -1,3 +1,7 @@
+2008-03-07  Teresa Thomas  <tthomas@redhat.com>
+
+	* fhpd.java (main): Add event to handle SIGINT.
+
 2008-03-07  Sami Wagiaalla  <swagiaal@redhat.com>
 
 	ProcRunUtil.java: Renamed ProcRunningUtil to ProcRunUtil.
diff --git a/frysk-core/frysk/bindir/fhpd.java b/frysk-core/frysk/bindir/fhpd.java
index efc8520..af1a5bc 100644
--- a/frysk-core/frysk/bindir/fhpd.java
+++ b/frysk-core/frysk/bindir/fhpd.java
@@ -42,6 +42,7 @@ package frysk.bindir;
 import frysk.hpd.CoreCommand;
 import frysk.hpd.LoadCommand;
 import frysk.hpd.AttachCommand;
+import frysk.hpd.SigIntHandler;
 import frysk.event.Event;
 import java.io.FileInputStream;
 import java.io.IOException;
@@ -173,6 +174,8 @@ public class fhpd {
         parser.setHeader("Usage: fhpd <PID> || fhpd <EXEFILE> || fhpd <COREFILE> [<EXEFILE>]");
         parser.parse(args);
 	Manager.eventLoop.add(new CommandLine());
+	// Add event to handle Ctrl-C signal
+	Manager.eventLoop.add(SigIntHandler.fhpd);
 
 	// Run the event loop then exit when it exits (or crashes).
 	Manager.eventLoop.run();
diff --git a/frysk-core/frysk/hpd/CLI.java b/frysk-core/frysk/hpd/CLI.java
index f8f16c8..dc85569 100644
--- a/frysk-core/frysk/hpd/CLI.java
+++ b/frysk-core/frysk/hpd/CLI.java
@@ -55,13 +55,16 @@ import java.util.WeakHashMap;
 import frysk.debuginfo.DebugInfo;
 import frysk.debuginfo.DebugInfoFrame;
 import frysk.debuginfo.DebugInfoStackFactory;
+import frysk.proc.Manager;
 import frysk.proc.Proc;
 import frysk.proc.Task;
 import frysk.rt.ProcTaskIDManager;
 import frysk.stepping.SteppingEngine;
 import frysk.stepping.TaskStepEngine;
+import frysk.sys.Signal;
 import frysk.util.CountDownLatch;
 import frysk.util.WordWrapWriter;
+import frysk.event.SignalEvent;
 import frysk.expr.Expression;
 import frysk.expr.ScratchSymTab;
 import frysk.expr.ExprSymTab;
@@ -414,12 +417,31 @@ public class CLI {
         private Object monitor = new Object();
 
         public Object getMonitor () {
+            
+	    // Event to handle Ctrl-C signal received during
+	    // stepping.
+	    Manager.eventLoop.add(new SignalEvent(Signal.INT) {
+		public void execute () {
+		    System.out.println ("Stepping engine: Got SIGINT");
+		    // Notify the stepping engine to stop waiting.
+		    synchronized (monitor) {
+			monitor.notify();
+		    }
+		    // Set Ctrl-C handler back to fhpd settings
+		    Manager.eventLoop.add(SigIntHandler.fhpd);
+		}
+	    });  
+	    
             return this.monitor;
         }
 
         public void update (Observable observable, Object arg) {
             TaskStepEngine tse = (TaskStepEngine) arg;
-            if (!tse.isAlive()) {
+            
+	    // Ensure Ctrl-C handler is set back to fhpd settings
+	    Manager.eventLoop.add(SigIntHandler.fhpd);
+            
+	    if (!tse.isAlive()) {
 		addMessage(tse.getMessage(), Message.TYPE_VERBOSE);
 		tse.setMessage("");
 		flushMessages();
diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog
index 4f4d065..77f9c1e 100644
--- a/frysk-core/frysk/hpd/ChangeLog
+++ b/frysk-core/frysk/hpd/ChangeLog
@@ -1,3 +1,10 @@
+2008-03-07  Teresa Thomas  <tthomas@redhat.com>
+.
+	* CLI.java (SteppingObserver.getMonitor): Add events to
+	handle SIGINT.
+	* ShellCommand.java (interpretCommand): Ditto.	
+	* SigIntHandler.java: New.
+
 2008-03-05  Tom Tromey  <tromey@redhat.com>
 
 	Bug 5809
diff --git a/frysk-core/frysk/hpd/ShellCommand.java b/frysk-core/frysk/hpd/ShellCommand.java
index 11c4b33..79f84a1 100644
--- a/frysk-core/frysk/hpd/ShellCommand.java
+++ b/frysk-core/frysk/hpd/ShellCommand.java
@@ -48,6 +48,7 @@ import frysk.proc.TaskObserver;
 import frysk.sys.FileDescriptor;
 import frysk.util.CountDownLatch;
 import frysk.util.PtyTerminal;
+import frysk.event.SignalEvent;
 import frysk.isa.signals.Signal;
 
 class ShellCommand extends NoOptsCommand {
@@ -79,7 +80,16 @@ class ShellCommand extends NoOptsCommand {
 	// Set terminal to initial setting.
 	PtyTerminal.setToInitConsole(FileDescriptor.in);
 
-	// Request an attached proc to execute command.
+	// SIGINT handling for shell command.
+	Manager.eventLoop.add(new SignalEvent(frysk.sys.Signal.INT) {
+	    public void execute () {
+		// Prints this message and gets out
+		// of shell command.
+		System.out.println ("shell: Got SIGINT");
+	    }
+	});
+	
+	// Request for an attached proc to execute the command.
   	Manager.host.requestCreateAttachedProc(command,
 					       new TaskObserver.Attached() {  	    
   	    public Action updateAttached (Task task)
@@ -122,6 +132,9 @@ class ShellCommand extends NoOptsCommand {
   	    }
   	}  	  	
   	
+	// Set Ctrl-C handler back to fhpd settings
+	Manager.eventLoop.add(SigIntHandler.fhpd);
+	
   	// Set terminal back to fhpd settings, i.e. character buffered.
 	PtyTerminal.setToCharBufferedConsole(FileDescriptor.in);
     }
diff --git a/frysk-core/frysk/hpd/TestShellCommand.java b/frysk-core/frysk/hpd/SigIntHandler.java
similarity index 80%
copy from frysk-core/frysk/hpd/TestShellCommand.java
copy to frysk-core/frysk/hpd/SigIntHandler.java
index 2bb44e0..235d9f0 100644
--- a/frysk-core/frysk/hpd/TestShellCommand.java
+++ b/frysk-core/frysk/hpd/SigIntHandler.java
@@ -39,17 +39,25 @@
 
 package frysk.hpd;
 
+import frysk.event.SignalEvent;
+import frysk.sys.Signal;
+
 /**
- * This class tests the "shell" command.
+ * Events to handle Cntrl-C signal.
  */
 
-public class TestShellCommand extends TestLib {
-    
-    public void testShellCommand() {
-	e = new HpdTestbed();
-	e.sendCommandExpectPrompt("shell echo $$", ".*[0-9]+.*");
-	e.sendCommandExpectPrompt("shell blahBLAHblah", ".*command not found.*");
-	e.sendCommandExpectPrompt("shell -help", ".*shell <command string>.*");
-	e.close();
-    }
+public class SigIntHandler {
+
+    /**
+     * This event overrides the default behaviour of 
+     * SIGINT on an fhpd process.
+     */
+    public static final SignalEvent fhpd = new SignalEvent(Signal.INT) {
+	public void execute () {
+	    // Do nothing. Just print prompt again
+	    // XXX: Reader will continue reading input
+	    // till a return character is received.
+	    System.out.print("\n(fhpd) ");
+	}
+    };
 }
\ No newline at end of file


hooks/post-receive
--
frysk system monitor/debugger


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-03-07 20:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-07 20:33 [SCM] master: Ctrl-C handling for fhpd tthomas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).