Samn has asked for the wisdom of the Perl Monks concerning the following question:

Replies are listed 'Best First'.
Re: Automatically restarting process
by Abigail-II (Bishop) on Jul 25, 2002 at 16:12 UTC
    Using pseudo-code:
    repeat fork & exec bot; wait; # That's the system call wait()! until doomsday;
    Abigail
      Abigail-II's suggestions is best on *nix. If you are stuck on Windows I would recommend Win32::Process
      use Win32::Process; my $ProcessObj; while(1) { Win32::Process::Create( $ProcessObj, $appname, $cmdline, $iflags, $cflags, $curdir) or die; $ProcessObj->Wait(INFINITE); }

      flounder

Re: Automatically restarting process
by krujos (Curate) on Jul 25, 2002 at 15:52 UTC
    You can launch the bot and watch the process or the connection (I am not sure if you mean the whole process dies, or just becomes disconnected). In your loop look to see if the process is still active, if he is not turn him back on.
    something like
    launch bot while (1) if [ bot not connected, alive or whatever] restart, reconnect or whatever... end while
    Depending on the exact implementation and platform this may be rolled up for you in a module.
    good luck
Re: Automatically restarting process
by DamnDirtyApe (Curate) on Jul 25, 2002 at 15:45 UTC

    Is there some way of determining whether or not your bot is currently running? Without knowing anything about how your bot works, I would think you'd want to do it something like this:

    unless ( $stop_checking ) { &bot unless $bot_is_running ; }

    _______________
    D a m n D i r t y A p e
    Home Node | Email