in reply to Re: Restarting perl script by itself
in thread Restarting perl script by itself

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.

Replies are listed 'Best First'.
Re^3: Restarting perl script by itself
by zentara (Cardinal) on Sep 16, 2011 at 17:24 UTC
    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.
Re^3: Restarting perl script by itself
by afoken (Chancellor) on Sep 16, 2011 at 17:28 UTC

    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". ;-)