This is the mail archive of the mailing list for the frysk project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Kill and refresh

Mark Wielaard wrote:

I had some issues trying to write some tests that I tracked down to some
TaskStates and the LinuxHost not handling disappearing/killed processes
nicely. I tried to write a self contained test case, but I found it only
triggered when running the EventLoop in its own Thread. This probably
means that I haven't pinned down the real sequence of events causing
this. Or maybe my idea of how process creation, Host process discovery
and process disappearance should interact is not correct.

Attached is a testcase that shows (at least for me) that a Task in the
detached state can get a handleTerminatedEvent() call that it doesn't
know how to handle.

A detached process shouldn't be generating a terminated event; ah, it looks like it is a detached child process - can you check the parent-pid of the process to see what it is? I suspect the wait-pid is comming from the child exiting, rather than it being some how attached. Consequently, I'm not sure if it should be treated as a bug or wart?


For reference I'll provide some commentary on the code (but the above is more interesting):

Could someone take a look/try this testcase out?
And tell me whether it also fails for them and/or whether this is
supposed to work or not?



Index: frysk/proc/
RCS file: frysk/proc/
diff -N frysk/proc/
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ frysk/proc/ 13 Jul 2006 16:02:27 -0000
@@ -0,0 +1,187 @@
+// This file is part of the program FRYSK.
+// Copyright 2006, 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
+// the Free Software Foundation; version 2 of the License.
+// FRYSK is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// General Public License for more details.
+// +// You should have received a copy of the GNU General Public License
+// along with FRYSK; if not, write to the Free Software Foundation,
+// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+// +// In addition, as a special exception, Red Hat, Inc. gives You the
+// additional right to link the code of FRYSK with code not covered
+// under the GNU General Public License ("Non-GPL Code") and to
+// distribute linked combinations including the two, subject to the
+// limitations in this paragraph. Non-GPL Code permitted under this
+// exception must only link to the code of FRYSK through those well
+// defined interfaces identified in the file named EXCEPTION found in
+// the source code files (the "Approved Interfaces"). The files of
+// Non-GPL Code may instantiate templates or use macros or inline
+// functions from the Approved Interfaces without causing the
+// resulting work to be covered by the GNU General Public
+// License. Only Red Hat, Inc. may make changes or additions to the
+// list of Approved Interfaces. You must obey the GNU General Public
+// License in all respects for all of the FRYSK code and other code
+// used in conjunction with FRYSK except the Non-GPL Code covered by
+// this exception. If you modify this file, you may extend this
+// exception to your version of the file, but you are not obligated to
+// do so. If you do not wish to provide this exception without
+// modification, you must delete this exception statement from your
+// version and license this file solely under the GPL without
+// exception.
+package frysk.proc;
+import frysk.sys.*;
+import frysk.event.*;
+ * Check that a program can be killed/disappear without the
+ * core going crazy.
+ */
+public class TestKill
+ extends TestLib
+ // The eventloop that needs to be stopped at the end of the test.
+ EventLoopRunner eventloop;
+ // Process ids that need to be cleaned up.
+ int pid1, pid2;
+ // Monitor that gets notified as soon as some event occured.
+ Object monitor = new Object();
+ public void setUp()
+ {
super.setUp ();
+ pid1 = pid2 = -1;
+ eventloop = new EventLoopRunner();
+ eventloop.start();
+ }
+ public void tearDown()
+ {
+ try
+ {
+ if (pid1 != -1)
+ Signal.kill(pid1, Sig.KILL);
+ }
+ catch(Errno e)
+ {
+ // Already killed
+ }
+ try
+ {
+ if (pid2 != -1)
+ Signal.kill(pid2, Sig.KILL);
+ }
+ catch(Errno e)
+ {
+ // Already killed
+ }
+ eventloop.requestStop();
+ }
+ public void testKill()
+ {
+ // Create a detached process.
+ String command = getExecPrefix() + "funit-loop";
+ pid1 = Fork.daemon (null, null, null, new String[] { command });
You'll want a way of knowing that the funit-loop process is really running, funit-child, for instance, does this be sending frysk a signal(2) once it is fully set up - frysk runs the event loop until it sees that signal.
+ ProcId procId1 = new ProcId(pid1);
+ // Try to find it
Call runPending() here, it will process the refresh.
+ // No, lets kill it...
+ Signal.kill(pid1, Sig.KILL);
This should generate an event.

You just want to know that the event has been received and processed. Will this event have an effect that can be observed? If there is, add an observer to it, and then when it occures, request the event loop to shut down.
+main (int argc, char **argv)
+ // Happily count to infinity
+ int i = 0;
+ while(1)
+ i++;
+ return 0;
suggest having a timer as well (default 5 seconds) so that if frysk crashes this isn't left around (at least long term).


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]