in reply to It works, and then it doesn't...connecting to a daemon over the net

You have not given enough context to say what is happening. For example, you say "the 'run' button hangs". What does that mean? Is this a Tk application?

The code: exec() unless fork() is not robust. If fork() fails, it returns undef. In this case your code is going to do an exec in the main process and not give an error. You really shouldn't try to write a one-liner here because there are three cases (1) parent (2) child (3) fork failed.

One general-purpose debugging technique:

# do this once (obviously, I hope) use IO::File; open LOG, ">>log.out" or die "opening log.out: $!\n"; LOG->autoflush(1); printf LOG "PROC $$: %d %s run starts %s\n", time, __FILE__, scalar(localtime); # put lots of these throughout your program printf LOG "PROC $$: %d %s(%d)\n", time, __FILE__, __LINE__;
If you look at the times, you can see where your program is waiting. Scatter these liberally through your program. You may be surprised.

Replies are listed 'Best First'.
Re: Re: It works, and then it doesn't...connecting to a daemon over the net
by seaver (Pilgrim) on Jun 12, 2003 at 21:23 UTC
    It's an applet, the applet has a 'run' button, if I re-send a request before the first is finished, the java button doesnt 'de-click' until the first is finished and the second has started, thus it looks like it hangs.

    when you say 'through your program', do you mean the daemon, or the program the daemon is trying to run?

    S

Re: Re: It works, and then it doesn't...connecting to a daemon over the net
by seaver (Pilgrim) on Jun 18, 2003 at 17:07 UTC
    Dear Thelonius, After much messing around with your method of checking times, I've basically found where my daemon hangs and it still makes no sense whatsoever.

    basically, the daemon hangs right at the start of the request. My very first

    use IO::File; open LOG, ">>log.out" or die "opening log.out: $!\n"; LOG->autoflush(1); printf LOG "PROC $$: %d %s run starts %s\n", time, __FILE__, scalar(localtime);

    for the second request (remember, it is sent while the first program is running) does NOT APPEAR UNTIL THE FIRST REQUEST HAS FINISHED!!!!

    This means that activation of the very function, 'go' does not start until monster has finished running...does this make sense to anyone?

    it seems like the fork is not done completely or something, so though the 'return' happens easily after the first time, 'go' is still waiting for the fork to finish....

    any ideas?

    thanks

    Sam