From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2715 invoked by alias); 26 Jun 2008 18:17:32 -0000 Received: (qmail 2687 invoked by uid 9519); 26 Jun 2008 18:17:31 -0000 Date: Thu, 26 Jun 2008 18:17:00 -0000 Message-ID: <20080626181731.2672.qmail@sourceware.org> From: rmoseley@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Fix bz 6696(problem with kill command). X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 4ee203efb3be5d328cfe419d1f9c24f17e7ea32e X-Git-Newrev: 6769775d04e116c60ba53d52d7e509ceb4cbbbdb 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-q2/txt/msg00400.txt.bz2 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 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 + + * CLI.java: Fix bz 6696. + * DetachCommand.java: Ditto. + * KillCommand.java: Ditto. + * TestKillCommand.java: Add test for fix. + + 2008-06-17 Teresa Thomas * 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