This is the mail archive of the frysk-cvs@sources.redhat.com mailing list for the frysk project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[SCM] master: Fix bz 6696(problem with kill command).


The branch, master has been updated
       via  6769775d04e116c60ba53d52d7e509ceb4cbbbdb (commit)
      from  4ee203efb3be5d328cfe419d1f9c24f17e7ea32e (commit)

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

- Log -----------------------------------------------------------------
commit 6769775d04e116c60ba53d52d7e509ceb4cbbbdb
Author: Rick Moseley <rmoseley@localhost.localdomain>
Date:   Thu Jun 26 13:16:38 2008 -0500

    Fix bz 6696(problem with kill command).
    
    * CLI.java: Fix bz 6696.
    * DetachCommand.java: Ditto.
    * KillCommand.java: Ditto.
    * TestKillCommand.java: Add test for fix.

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

Summary of changes:
 frysk-core/frysk/hpd/CLI.java             |    4 +++
 frysk-core/frysk/hpd/ChangeLog            |    8 +++++++
 frysk-core/frysk/hpd/DetachCommand.java   |    7 ++++-
 frysk-core/frysk/hpd/KillCommand.java     |   12 +++++-----
 frysk-core/frysk/hpd/TestKillCommand.java |   31 +++++++++++++++++++++++++++++
 5 files changed, 54 insertions(+), 8 deletions(-)

First 500 lines of diff:
diff --git a/frysk-core/frysk/hpd/CLI.java b/frysk-core/frysk/hpd/CLI.java
index dd1f97f..eb1533c 100644
--- a/frysk-core/frysk/hpd/CLI.java
+++ b/frysk-core/frysk/hpd/CLI.java
@@ -185,6 +185,10 @@ public class CLI {
         // Assign this proc to the passed in procID 
         else
             idManager.manageProc(proc, this.taskID);
+        // Add this process to the runningProcs table
+        synchronized (this) {
+		this.runningProcs.add(proc);
+	    }
     }
 
     /**
diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog
index 5678226..87a1322 100644
--- a/frysk-core/frysk/hpd/ChangeLog
+++ b/frysk-core/frysk/hpd/ChangeLog
@@ -1,3 +1,11 @@
+2008-06-26  Rick Moseley  <rmoseley@redhat.com>
+
+	* CLI.java: Fix bz 6696.
+	* DetachCommand.java: Ditto.
+	* KillCommand.java: Ditto.
+	* TestKillCommand.java: Add test for fix.
+
+
 2008-06-17  Teresa Thomas  <tthomas@redhat.com>
 
 	* TestWatchCommand.java (testWritePrevValue): New test.
diff --git a/frysk-core/frysk/hpd/DetachCommand.java b/frysk-core/frysk/hpd/DetachCommand.java
index b76a603..e98e5a3 100644
--- a/frysk-core/frysk/hpd/DetachCommand.java
+++ b/frysk-core/frysk/hpd/DetachCommand.java
@@ -1,6 +1,6 @@
 // This file is part of the program FRYSK.
 //
-// Copyright 2005, 2006, 2007 Red Hat Inc.
+// Copyright 2005, 2006, 2007, 2008 Red Hat Inc.
 //
 // FRYSK is free software; you can redistribute it and/or modify it
 // under the terms of the GNU General Public License as published by
@@ -72,12 +72,15 @@ class DetachCommand extends ParameterizedCommand {
 	    synchronized (cli) {
 		startedByRun = cli.runningProcs.contains(proc);
 	    }
-	    if (startedByRun)
+	    if (!startedByRun)
 		continue;
 	    // Delete all breakpoints.
 	    if (cli.steppingObserver != null)
 		cli.getSteppingEngine().removeObserver(cli.steppingObserver,
 			proc, true);
+	    synchronized (cli) {
+		cli.runningProcs.remove(proc);
+	    }
 	}
     }
 
diff --git a/frysk-core/frysk/hpd/KillCommand.java b/frysk-core/frysk/hpd/KillCommand.java
index a05f1cf..cf7dabc 100644
--- a/frysk-core/frysk/hpd/KillCommand.java
+++ b/frysk-core/frysk/hpd/KillCommand.java
@@ -156,6 +156,9 @@ public class KillCommand extends ParameterizedCommand {
 		procPID = proc.getPid();
 		// Now, call the Proc object to kill off the executable(s)
 		proc.requestKill();
+		synchronized (cli) {
+		    cli.runningProcs.remove(proc);
+		}
 		if ((pid > 0))
 		    return true;
 	    }
@@ -202,17 +205,14 @@ public class KillCommand extends ParameterizedCommand {
 			+ " that was created from " + proc.getExeFile().getSysRootedPath(),
 			Message.TYPE_NORMAL);
 		    proc.requestKill();
+		    synchronized (cli) {
+			cli.runningProcs.remove(proc);
+		    }
 		    tempId = procId;
 		    returnProc = true;
 		}
 	    }
 	}
-	if (returnProc) {
-	    synchronized (cli) {
-		// Clear the running procs set
-		cli.runningProcs.clear();
-	    }
-	}
 	return returnProc;
     }
 
diff --git a/frysk-core/frysk/hpd/TestKillCommand.java b/frysk-core/frysk/hpd/TestKillCommand.java
index 4a5446c..e3711d9 100644
--- a/frysk-core/frysk/hpd/TestKillCommand.java
+++ b/frysk-core/frysk/hpd/TestKillCommand.java
@@ -196,6 +196,37 @@ java.lang.NullPointerException
     }
     
     /**
+     * Test killing of a single proc NOT using the PID
+     */
+    public void testKillAfterAttach() {
+	SlaveOffspring newProc = SlaveOffspring.createDaemon();
+	int pid = newProc.getPid().intValue();
+	e = new HpdTestbed();
+	e.sendCommandExpectPrompt("attach " + pid, "Attached to process " + pid + ".*");
+	e.sendCommandExpectPrompt("kill", "Killing process " + pid + ".*");
+	try { Thread.sleep(500); } catch (Exception e) { }
+	e.send("quit\n");
+	e.expect("Quitting\\.\\.\\..*");
+	e.close();
+    }
+    
+    /**
+     * Test killing of a single proc and then running
+     */
+    public void testKillAfterAttachThenRun() {
+	SlaveOffspring newProc = SlaveOffspring.createDaemon();
+	int pid = newProc.getPid().intValue();
+	e = new HpdTestbed();
+	e.sendCommandExpectPrompt("attach " + pid, "Attached to process " + pid + ".*");
+	e.sendCommandExpectPrompt("kill", "Killing process " + pid + ".*");
+	try { Thread.sleep(500); } catch (Exception e) { }
+	e.sendCommandExpectPrompt("run", "running with this command.*");
+	e.send("quit\n");
+	e.expect("Quitting\\.\\.\\..*");
+	e.close();
+    }
+    
+    /**
      * Test entering a non-integer as a PID
      */
     public void testKillError() {


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]