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

Hi people, how i do for continue the script when the client abort conection? When i create a child process, it die when the parent process finish? Well, thx all ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Thank people, now, i know how to make continue the child process. But my question ... how i do for continue the script running when the web client conection abort. Obviusly, the script run in web server and have a very big regexp than take 10 minute for process, in this time, the web server connection close, because (i suppoust) expire the time (timeout). Well i think that a child process resolve this problem, and i know how to continue... But only for know.... How i do for continue running the script in the server when the client connection abort, żIs this possible? Thank, and i hope don't write nothing bad, becouse my english is very bad.

Replies are listed 'Best First'.
Re: Continue when the client abort
by castaway (Parson) on Mar 27, 2004 at 08:52 UTC
    You'll have to give a little more detail.. What sort of client/child process are you talking about? A fork? A socket? A system call?? Maybe you can show the script, or the part of it that does this..

    C.

Re: Continue when the client abort
by UnderMine (Friar) on Mar 27, 2004 at 12:02 UTC
    Again without detail it is very hard to give any advice but it might be worth looking into daemons and independent child processes.

    You might also be running a batch job in a CGI which would be better run as a daemon that processes a queue with the CGI pushing things onto that queue.

    But please can we have more detail.

    Hope it helps
    UnderMine

Re: Continue when the client abort
by Grygonos (Chaplain) on Mar 27, 2004 at 14:29 UTC
    It sounds like you want the processes to be associated but for it not to be a child-parent type relationship...?!?!?! just making sure i'm reading you right? can you please post some more info so we can help you

    Grygonos
Re: Continue when the client abort
by cees (Curate) on Mar 27, 2004 at 20:48 UTC
    how i do for continue the script when the client abort conection? When i create a child process, it die when the parent process finish?

    You need to dissociate the child process from the parent in order for the child process to continue after the parent dies. You can do this by calling setsid which is part of the POSIX module.

    See the perlipc docs and search for "Complete Dissociation of Child from Parent" for an example of how to do this.

    - Cees

Re: Continue when the client abort
by cLive ;-) (Prior) on Mar 28, 2004 at 03:06 UTC
    use POSIX; # ... if (!defined($pid=fork()) { # fork fails } elsif($pid) { # parent waitpid(-1, WNOHANG); # run code here } else { # child }
    or something like that :)

    .02

    cLive ;-)