From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32312 invoked by alias); 25 Mar 2008 18:40:23 -0000 Received: (qmail 32286 invoked by uid 9519); 25 Mar 2008 18:40:22 -0000 Date: Tue, 25 Mar 2008 18:40:00 -0000 Message-ID: <20080325184022.32271.qmail@sourceware.org> From: rmoseley@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Kill all processes before rerunning any(bz # 5985). X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: fb7760cc23ce26340eb92fd3a1b836d16c0eb357 X-Git-Newrev: 9c6237cfe7385cb4d444a00c92de1a7668cae0ed Mailing-List: contact frysk-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: frysk-cvs-owner@sourceware.org Reply-To: frysk@sourceware.org X-SW-Source: 2008-q1/txt/msg00423.txt.bz2 The branch, master has been updated via 9c6237cfe7385cb4d444a00c92de1a7668cae0ed (commit) from fb7760cc23ce26340eb92fd3a1b836d16c0eb357 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 9c6237cfe7385cb4d444a00c92de1a7668cae0ed Author: Rick Moseley Date: Tue Mar 25 13:38:50 2008 -0500 Kill all processes before rerunning any(bz # 5985). * StartRun.java: Kill all processes on a re-run before running them(bz #5985). * TestRunCommand.java: Add new bug found(#5984). ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/hpd/ChangeLog | 6 ++ frysk-core/frysk/hpd/StartRun.java | 99 +++++++++++++++++++---------- frysk-core/frysk/hpd/TestRunCommand.java | 28 +++------ 3 files changed, 80 insertions(+), 53 deletions(-) First 500 lines of diff: diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog index ef69eeb..ee8662f 100644 --- a/frysk-core/frysk/hpd/ChangeLog +++ b/frysk-core/frysk/hpd/ChangeLog @@ -1,3 +1,9 @@ +2008-03-25 Rick Moseley + + * StartRun.java: Kill all processes on a re-run before + running them(bz #5985). + * TestRunCommand.java: Add new bug found(#5984). + 2008-03-24 Stan Cox * ListCommand.java (listOneTask): New. Refactored from interpret. diff --git a/frysk-core/frysk/hpd/StartRun.java b/frysk-core/frysk/hpd/StartRun.java index 8a3f971..bc3fdb4 100644 --- a/frysk-core/frysk/hpd/StartRun.java +++ b/frysk-core/frysk/hpd/StartRun.java @@ -47,6 +47,7 @@ import frysk.proc.Task; import frysk.proc.TaskAttachedObserverXXX; import frysk.proc.ProcTasksAction; import frysk.util.CountDownLatch; +import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -58,6 +59,8 @@ import java.util.List; */ abstract class StartRun extends ParameterizedCommand { + final ArrayList procList = new ArrayList(); + StartRun(String command, String help1, String help2) { super(command, help1, help2); } @@ -123,48 +126,74 @@ abstract class StartRun extends ParameterizedCommand { public void interpretCmd(CLI cli, Input cmd, Object options, boolean runToBreak) { + // See if there are any tasks to be killed + if (killProcs(cli)) { // See if there are any tasks in the current target set - Iterator foo = cli.targetset.getTaskData(); - int oldPid = -1; - if (foo.hasNext()) { - // Clear the parameters for this process TaskData taskData = null; + Iterator foo = procList.iterator(); while (foo.hasNext()) { taskData = (TaskData) foo.next(); Task task = taskData.getTask(); - // Need only one kill per PID(proc) if proc is running already - if (task.getProc().getPid() != oldPid && - task.getProc().getPid() > 0) { - cli.execCommand("kill " + task.getProc().getPid() + "\n"); - int taskid = taskData.getParentID(); - run(cli, cmd, task.getProc(), runToBreak, taskid); - oldPid = task.getProc().getPid(); - } else { - int taskid = taskData.getParentID(); - // Take care of loaded procs - if (!cli.loadedProcs.isEmpty() && - cli.loadedProcs.containsKey(task.getProc())) { - run(cli, cmd, task.getProc(), runToBreak, taskid); - synchronized (cli) { - cli.loadedProcs.remove(task.getProc()); - } - } - // Take care of core procs - else if (!cli.coreProcs.isEmpty() && - cli.coreProcs.containsKey(task.getProc())) { - run(cli, cmd, task.getProc(), runToBreak, taskid); - synchronized (cli) { - cli.coreProcs.remove(new Integer(taskid)); - } - } - } - } - return; - // } - } else { + run(cli, cmd, task.getProc(), runToBreak, taskData.getParentID()); + } + return; + } + // Take care of loaded procs + Iterator foo = cli.targetset.getTaskData(); + if (!foo.hasNext()) { cli.addMessage("No procs in targetset to run", Message.TYPE_NORMAL); return; } + while (foo.hasNext()) { + TaskData taskData = (TaskData) foo.next(); + Task task = taskData.getTask(); + if (!cli.loadedProcs.isEmpty() && + cli.loadedProcs.containsKey(task.getProc())) { + run(cli, cmd, task.getProc(), runToBreak, taskData.getParentID()); + synchronized (cli) { + cli.loadedProcs.remove(task.getProc()); + } + } + // Take care of core procs + else if (!cli.coreProcs.isEmpty() && + cli.coreProcs.containsKey(task.getProc())) { + run(cli, cmd, task.getProc(), runToBreak, taskData.getParentID()); + synchronized (cli) { + cli.coreProcs.remove(new Integer(taskData.getParentID())); + } + } + } + + } + + /** + * killProcs loops through the current target set to see if there are any + * tasks to kill, the philosophy being that all tasks should be killed before + * + */ + + private boolean killProcs(CLI cli) { + Iterator foo = cli.targetset.getTaskData(); + // No procs in target set return false + if (!foo.hasNext()) { + return false; + } + TaskData taskData = null; + int oldPid = -1; + while (foo.hasNext()) { + taskData = (TaskData) foo.next(); + Task task = taskData.getTask(); + if (task.getProc().getPid() != oldPid && + task.getProc().getPid() > 0) { + procList.add(taskData); + cli.execCommand("kill " + task.getProc().getPid() + "\n"); + oldPid = task.getProc().getPid(); + } + } + if (procList.isEmpty()) + return false; + + return true; } /** @@ -221,6 +250,8 @@ abstract class StartRun extends ParameterizedCommand { } private String asString(String[] args) { + if (args == null || args.length <= 0) + return ""; StringBuffer b = new StringBuffer(args[0]); for (int i = 1; i < args.length; i++) { b.append(" "); diff --git a/frysk-core/frysk/hpd/TestRunCommand.java b/frysk-core/frysk/hpd/TestRunCommand.java index f144ebd..1c769bb 100644 --- a/frysk-core/frysk/hpd/TestRunCommand.java +++ b/frysk-core/frysk/hpd/TestRunCommand.java @@ -89,14 +89,8 @@ public class TestRunCommand extends TestLib { //e.sendCommandExpectPrompt("focus","Target set.*\\[0\\.0\\]\t\t([0-9]+)" + // "\t([0-9]+)\r\n" + "\\[0\\.1\\]\t\t([0-9]+)\t([0-9]+)\r\n"); //try { Thread.sleep(1000); } catch (Exception e) {} - e.send("run\n"); - e.expect(".*Killing process ([0-9])+.*"); - e.expect("\\[0\\.0\\] Loaded executable file.*"); - e.expect("Attached to process ([0-9])+.*"); - e.expect("Running process ([0-9])+.*"); - //e.sendCommandExpectPrompt("run", "Killing process ([0-9])+.*" + - // "Loaded executable file.*" + "Attached to process ([0-9])+.*" + - // "Running process ([0-9])+.*"); + e.sendCommandExpectPrompt("run", "Killing process ([0-9])+.*running.*" + + "Attached to process ([0-9]+).*Running process ([0-9]+).*"); //e.send("quit\n"); //e.expect("Quitting\\.\\.\\."); e.close(); @@ -153,7 +147,7 @@ public class TestRunCommand extends TestLib { * just rerun the currently running process and place in in the same place in the target set. */ public void testRunCommandTwoProcesses() { - if (unresolved(5615)) + if (unresolved(5984)) return; e = new HpdTestbed(); e.sendCommandExpectPrompt("load " + Config.getPkgLibFile("funit-hello").getPath(), @@ -163,16 +157,12 @@ public class TestRunCommand extends TestLib { e.sendCommandExpectPrompt("focus", "Target set.*\\[0\\.0\\]\t\t0\t0.*"+ "\\[1\\.0\\]\t\t0*\\t0.*"); e.sendCommandExpectPrompt("run", "Attached to process ([0-9]+).*Attached to process ([0-9]+).*" + - "starting.*" + "Running process ([0-9]+).*starting.*Running process ([0-9]+).*"); - //e.sendCommandExpectPrompt("run", "Killing process ([0-9]+).*Loaded executable file.*" + - // "Attached to process ([0-9]+).*starting.*Running process ([0-9]+).*starting.*" + - // "Running process ([0-9]+).*"); - e.send("run\n"); - e.expect("Killing process ([0-9]+).*"); - e.expect("\\[1\\.0\\] Loaded executable file.*"); - e.expect("Attached to process ([0-9]+).*"); - e.expect("Running process ([0-9]+).*"); - e.sendCommandExpectPrompt("focus", "Target set.*\\[1\\.0\\]\t\t([0-9]+)\t([0-9]+).*" + + "running.*" + "Running process ([0-9]+).*running.*Running process ([0-9]+).*"); + e.sendCommandExpectPrompt("run", "Killing process ([0-9]+).*Killing process ([0-9]+).*" + + "Attached to process ([0-9]+).*running.*Running process ([0-9]+).*running.*" + + "Running process ([0-9]+).*"); + e.sendCommandExpectPrompt("focus", "Target set.*\\[0\\.0\\]\t\t([0-9]+)\t([0-9]+).*" + + "\\[0\\.1\\]\t\t([0-9]+).*\\t([0-9]+).*\\[1\\.0\\]\t\t([0-9]+)\t([0-9]+).*" + "\\[1\\.1\\]\t\t([0-9]+).*\\t([0-9]+).*"); e.send("quit\n"); e.expect("Quitting\\.\\.\\."); hooks/post-receive -- frysk system monitor/debugger