in reply to Keeping a loop alive

So you want an infinite loop? Then just use one:
while(1) { open(IN, "tcpdump -nelttti pflog0 2>&1 |"); while (<IN>) { $sth->execute($stuff); } close(IN); }

Makeshifts last the longest.

Replies are listed 'Best First'.
Re: Re: Keeping a loop alive
by fuzzyping (Chaplain) on May 31, 2003 at 16:12 UTC
    Nope, doesn't work. As soon as tcpdump dies, the rest of it closes gracefully. Perhaps I'm overcomplicating matters, but would it help to fork() the process, then monitor the status of the child? Doesn't seem as though that would be theoretically any different than doing the "while (1)" loop.

    -fp

    Update: Minor correction. If I manually kill tcpdump, the loop does successfully start a new tcpdump process. It's only when I flush the states, and my ssh connection is closed, that it appears to kill off everything. I'm starting to wonder if it isn't a problem with a controlling terminal?
      What is the "the rest of it", and of what is this rest?

      Makeshifts last the longest.

        Actually, it appears to be a controlling terminal problem. If I do $ ssh user@host 'perl script.pl &', then the behavior ceases to be a problem. Sorry for the incorrect analysis. :)

        -fp