public inbox for frysk-cvs@sourceware.org help / color / mirror / Atom feed
From: rmoseley@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Changes to implement "kill" command. Date: Wed, 12 Dec 2007 05:13:00 -0000 [thread overview] Message-ID: <20071212051328.4928.qmail@sourceware.org> (raw) 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 <rmoseley@localhost.localdomain> 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 <rmoseley@redhat.com> + + * 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 <scox@redhat.com> * 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 <rmoseley@redhat.com> + + * Proc.java (killRequest): New for "kill" command. + 2007-12-10 Petr Machata <pmachata@redhat.com> * 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 <rmoseley@redhat.com> + + * ProcTaskIDManager.java (clearProcIDs): New for "kill" command; + check for empty procList. + 2007-12-11 Andrew Cagney <cagney@redhat.com> * 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
reply other threads:[~2007-12-12 5:13 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=20071212051328.4928.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).