This code: if (attach == true) init(); else { File exe = new File(command[0]); if (exe.exists()) Manager.host.requestCreateAttachedProc(command, new CatchObserver()); else { System.err.println("fcatch: can't find executable!"); System.exit(1); } } has a race - the executable could be removed between the exe.exists() call and the requestCreateAttatchedProc call. The code should instead handle the exec failure in the attatched observer.
What should be done, beyond the following? public void addFailed (Object observable, Throwable w) { throw new RuntimeException("Failed to attach to created proc", w); }
(In reply to comment #1) > What should be done, beyond the following? > > public void addFailed (Object observable, Throwable w) > { > throw new RuntimeException("Failed to attach to created proc", w); > } Not much (And the test exe.exists() is removed) :-) Just make certain that it is propogated back to main() so it can report the error (in Throwable w) and exit.
This code segment has been rewritten. commit 5492baa03cd955076e3b9cc5305def492de72920 Author: Sami Wagiaalla <swagiaal@redhat.com> Date: Mon Mar 10 16:29:44 2008 -0400 swagiaal: converted fcatch to use ProcRunUtil. frysk-core/frysk/bindir/ChangeLog +2008-03-10 Sami Wagiaalla <swagiaal@redhat.com> + + * fcatch.java: Moved the bulk of the code to FCatch. + frysk-core/frysk/debuginfo/ChangeLog +2008-03-10 Sami Wagiaalla <swagiaal@redhat.com> + + * DebugInfoStackFactory.java: Added DEFAULT options. + frysk-core/frysk/util/ChangeLog +2008-03-10 Sami Wagiaalla <swagiaal@redhat.com> + + * FCatch.java: Now uses ProcRunUtil. + * TestFCatch.java: Deleted. +