public inbox for frysk-cvs@sourceware.org help / color / mirror / Atom feed
From: rmoseley@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Kill all processes before rerunning any(bz # 5985). Date: Tue, 25 Mar 2008 18:40:00 -0000 [thread overview] Message-ID: <20080325184022.32271.qmail@sourceware.org> (raw) 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 <rmoseley@dhcp-215.hsv.redhat.com> 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 <rmoseley@redhat.com> + + * 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 <scox@redhat.com> * 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
reply other threads:[~2008-03-25 18:40 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20080325184022.32271.qmail@sourceware.org \ --to=rmoseley@sourceware.org \ --cc=frysk-cvs@sourceware.org \ --cc=frysk@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).