From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4973 invoked by alias); 12 Dec 2007 05:13:32 -0000 Received: (qmail 4944 invoked by uid 9519); 12 Dec 2007 05:13:29 -0000 Date: Wed, 12 Dec 2007 05:13:00 -0000 Message-ID: <20071212051328.4928.qmail@sourceware.org> From: rmoseley@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Changes to implement "kill" command. X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 6e677cc7a7c3844c9d40f64034ff41a4c24f5600 X-Git-Newrev: 9f669ff4f076bf2034c4ea507a8335f9d5237f72 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: 2007-q4/txt/msg00574.txt.bz2 The branch, master has been updated via 9f669ff4f076bf2034c4ea507a8335f9d5237f72 (commit) from 6e677cc7a7c3844c9d40f64034ff41a4c24f5600 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 9f669ff4f076bf2034c4ea507a8335f9d5237f72 Author: Rick Moseley Date: Tue Dec 11 23:12:34 2007 -0600 Changes to implement "kill" command. * ProcTaskIDManager.java (clearProcIDs): New for "kill" command; check for empty procList. * Proc.java (killRequest): New for "kill" command. * KillCommand.java: New. * TopLevelCommand.java: Changes for "kill" command. * RunCommand.java: Ditto. * GoCommand.java: Added message that process is now running. ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/hpd/ChangeLog | 7 ++++++ frysk-core/frysk/hpd/GoCommand.java | 2 + frysk-core/frysk/hpd/RunCommand.java | 3 +- frysk-core/frysk/hpd/TopLevelCommand.java | 3 +- frysk-core/frysk/proc/ChangeLog | 4 +++ frysk-core/frysk/proc/Proc.java | 33 ++++++++++++++++++++++++--- frysk-core/frysk/rt/ChangeLog | 5 ++++ frysk-core/frysk/rt/ProcTaskIDManager.java | 6 ++++- 8 files changed, 56 insertions(+), 7 deletions(-) First 500 lines of diff: diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog index 4e7bb82..d219173 100644 --- a/frysk-core/frysk/hpd/ChangeLog +++ b/frysk-core/frysk/hpd/ChangeLog @@ -1,3 +1,10 @@ +2007-12-11 Rick Moseley + + * KillCommand.java: New. + * TopLevelCommand.java: Changes for "kill" command. + * RunCommand.java: Ditto. + * GoCommand.java: Added message that process is now running. + 2007-12-11 Stan Cox * EvalCommands.java (Printer.TYPE): Change to use "String toPrint()" diff --git a/frysk-core/frysk/hpd/GoCommand.java b/frysk-core/frysk/hpd/GoCommand.java index ce74dab..9f3acde 100644 --- a/frysk-core/frysk/hpd/GoCommand.java +++ b/frysk-core/frysk/hpd/GoCommand.java @@ -65,6 +65,8 @@ class GoCommand extends ParameterizedCommand { Task task = (Task) taskIter.next(); if (!steppingEngine.isTaskRunning(task)) steppingEngine.continueExecution(task); + cli.addMessage("Running process " + task.getProc().getPid(), + Message.TYPE_NORMAL); } } else cli.addMessage("Not attached to any process", Message.TYPE_ERROR); diff --git a/frysk-core/frysk/hpd/RunCommand.java b/frysk-core/frysk/hpd/RunCommand.java index 5ae9fd3..ee78d69 100644 --- a/frysk-core/frysk/hpd/RunCommand.java +++ b/frysk-core/frysk/hpd/RunCommand.java @@ -68,7 +68,7 @@ class RunCommand extends ParameterizedCommand { private static class Runner implements TaskObserver.Attached { private final CLI cli; - final CountDownLatch latch = new CountDownLatch(1); + private CountDownLatch latch; Task launchedTask; Runner(CLI cli) { this.cli = cli; @@ -168,6 +168,7 @@ class RunCommand extends ParameterizedCommand { Manager.host.requestCreateAttachedProc(cmd.stringArrayValue(), runner); while (true) { try { + runner.latch = new CountDownLatch(1); runner.latch.await(); break; } catch (InterruptedException e) { diff --git a/frysk-core/frysk/hpd/TopLevelCommand.java b/frysk-core/frysk/hpd/TopLevelCommand.java index e133e7c..c6bf666 100644 --- a/frysk-core/frysk/hpd/TopLevelCommand.java +++ b/frysk-core/frysk/hpd/TopLevelCommand.java @@ -95,9 +95,10 @@ public class TopLevelCommand extends MultiLevelCommand { add(new GoCommand(), "g|o"); add(new HaltCommand(), "h|alt"); add(new Help(), "help"); + add(new KillCommand(), "k|ill"); add(new ListCommand(), "l|ist"); add(new LoadCommand(), "load"); - add(new MapsCommand(), "maps"); + add(new MapsCommand(), "maps"); add(new PeekCommand(), "peek"); Command quit = new QuitCommand(); add(quit, "exit"); diff --git a/frysk-core/frysk/proc/ChangeLog b/frysk-core/frysk/proc/ChangeLog index 910d7a9..a0a08a1 100644 --- a/frysk-core/frysk/proc/ChangeLog +++ b/frysk-core/frysk/proc/ChangeLog @@ -1,3 +1,7 @@ +2007-12-11 Rick Moseley + + * Proc.java (killRequest): New for "kill" command. + 2007-12-10 Petr Machata * TestTaskForkedObserver.java (testTaskVforkObserver): unresolved 5466. diff --git a/frysk-core/frysk/proc/Proc.java b/frysk-core/frysk/proc/Proc.java index e6f00a8..9d66815 100644 --- a/frysk-core/frysk/proc/Proc.java +++ b/frysk-core/frysk/proc/Proc.java @@ -53,7 +53,9 @@ import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; +import frysk.util.CountDownLatch; import frysk.event.Event; +import frysk.sys.Signal; /** * A UNIX Process, containing tasks, memory, ... @@ -64,7 +66,9 @@ public abstract class Proc protected static final Logger logger = Logger.getLogger(ProcLogger.LOGGER_ID); final ProcId id; - + + private CountDownLatch quitLatch; + public ProcId getId () { return id; @@ -159,7 +163,7 @@ public abstract class Proc { return this.host.get(new TaskId(this.getPid())); } - + /** * Return the Proc's command line argument list */ @@ -287,7 +291,7 @@ public abstract class Proc /** * Create a new, attached, running, process forked by Task. For the moment - * assume that the process will be immediatly detached; if this isn't the case + * assume that the process will be immediately detached; if this isn't the case * the task, once it has been created, will ram through an attached observer. * Note the chicken-egg problem here: to add the initial observation the Proc * needs the Task (which has the Observable). Conversely, for a Task, while it @@ -336,6 +340,27 @@ public abstract class Proc newState = null; return oldState; } + + /** + * killRequest handles killing off processes that either the commandline + * or GUI have designated need to be removed from the CPU queue. + */ + + public void requestKill() + { + Signal.KILL.kill(this.getPid()); + // Throw the countDown on the queue so that the command + // thread will wait until events provoked by Signal.kill() + // are handled. + this.quitLatch = new CountDownLatch(1); + Manager.eventLoop.add(new Event() { + public void execute() { + quitLatch.countDown(); + } + }); + this.performDetach(); + this.requestAbandon(); + } /** * Request that the Proc be forcefully detached. Quickly. @@ -351,7 +376,7 @@ public abstract class Proc * Request that the Proc be forcefully detached. Upon detach run the given * event. * - * @param e The event to run upon successfull detach. + * @param e The event to run upon successful detach. */ public void requestAbandonAndRunEvent (final Event e) { diff --git a/frysk-core/frysk/rt/ChangeLog b/frysk-core/frysk/rt/ChangeLog index a9ad9c0..0be3efc 100644 --- a/frysk-core/frysk/rt/ChangeLog +++ b/frysk-core/frysk/rt/ChangeLog @@ -1,3 +1,8 @@ +2007-12-11 Rick Moseley + + * ProcTaskIDManager.java (clearProcIDs): New for "kill" command; + check for empty procList. + 2007-12-11 Andrew Cagney * Line.java (UNKNOWN): New. diff --git a/frysk-core/frysk/rt/ProcTaskIDManager.java b/frysk-core/frysk/rt/ProcTaskIDManager.java index 1e8934e..6b32ba8 100644 --- a/frysk-core/frysk/rt/ProcTaskIDManager.java +++ b/frysk-core/frysk/rt/ProcTaskIDManager.java @@ -127,6 +127,10 @@ public class ProcTaskIDManager } return -1; } + + public synchronized void clearProcIDs() { + procList.clear(); + } public synchronized int getNumberOfProcs() { return procList.size(); @@ -198,7 +202,7 @@ public class ProcTaskIDManager public Action updateTerminated(Task task, boolean signal, int value) { Proc proc = task.getProc(); int id = getProcID(proc); - if (id < 0) + if (id < 0 || procList.isEmpty()) return Action.CONTINUE; synchronized (this) { ProcEntry entry = (ProcEntry)procList.get(id); hooks/post-receive -- frysk system monitor/debugger