in reply to Restarting perl script by itself

You're not forking a new process, running something in there, and then killing your current process. You're just doing a full-brain transplant on yourself.

Replies are listed 'Best First'.
Re^2: Restarting perl script by itself
by manua (Novice) on Sep 16, 2011 at 17:19 UTC
    Thanks.
    As per my understanding, exec will launch the new process, which should have a different process id than the parent process and parent process will not wait for the child process to complete.

    And, when the script complete, the parent process will be automatically killed.

    Let me know, what I am doing wrong.
      As per my understanding, exec will launch the new process

      No, exec replaces your current process.... a subtle difference.


      I'm not really a human, but I play one on earth.
      Old Perl Programmer Haiku ................... flash japh
        Thanks, thats the point I was missing.

      exec replaces one process with another one, keeping the PID, file descriptors, environment and so on. No single command launches a child process, keeping the parent process paralysed, and finally kills the helpless parent. Simply because that would be very inefficient.

      You should really RTFM, especially fork, exec, and system. Also read wait and waitpid.

      Understanding the concept of fork and exec is essential for writing software on Unix-like systems.

      Alexander

      --
      Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)