This is the mail archive of the frysk@sources.redhat.com 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] |
Hi,
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.
There's http://sourceware.org/frysk/javadoc/private/frysk/proc/TestLib.html#killDuringTearDown:intCould 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?
Thanks,
Mark
------------------------------------------------------------------------
Index: frysk/proc/TestKill.java
===================================================================
RCS file: frysk/proc/TestKill.java
diff -N frysk/proc/TestKill.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ frysk/proc/TestKill.java 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
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// 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;
+super.setUp ();
+ // Monitor that gets notified as soon as some event occured.
+ Object monitor = new Object();
+
+ public void setUp()
+ {
+ pid1 = pid2 = -1;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.
+ 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 });
+ ProcId procId1 = new ProcId(pid1);Call runPending() here, it will process the refresh.
+
+ // Try to find it
+ Manager.host.requestRefreshXXX(true);
+This should generate an event.
+ // No, lets kill it...
+ Signal.kill(pid1, Sig.KILL);
+intsuggest having a timer as well (default 5 seconds) so that if frysk crashes this isn't left around (at least long term).
+main (int argc, char **argv)
+{
+ // Happily count to infinity
+ int i = 0;
+ while(1)
+ i++;
+
+ return 0;
+}
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |