in reply to Re: Re: creating a fork process
in thread creating a fork process

This seems to word for me. Replace your "mail code" where I exec ('sleep 60')
#!/usr/bin/perl -w use strict; use CGI; use Errno qw(EAGAIN); my $pid; my $page = new CGI; print $page->header(), $page->start_html(); FORK: { if ($pid = fork()) { print <<HTML; <CENTER> In the parent process<BR> HTML print $page->end_html(); exit; } elsif (defined $pid) { print <<HTML; <CENTER> In the child process<BR> HTML print $page->end_html(); close STDIN; close STDOUT; close STDERR; exec ('sleep 60'); exit; } elsif ($! == EAGAIN) { print qq(Re-doing fork\n); sleep 5; redo FORK; } else { die qq(Can't fork: $!'n); } }
Hope this is of more help than the first posters comment. We all had to start once

Replies are listed 'Best First'.
Re: Re: Re: Re: creating a fork process
by richp (Initiate) on Feb 10, 2002 at 23:20 UTC
    ok thanks for the code, i appreciate it! i have a couple of things...the last line which says

    die qq(Can't fork: $!'n); is the 'n suppose to be \n?

    i did run your code in conjunction with what im doing but i still had the same problem, the browser was still communicating with the perl script the whole time the emails were being sent, almost as if the fork wasnt actually sending the emails and the perl script was? i did overcome this by placing close STDIN, STDOUT, STDERR all inside the parent process, that completely cut the parent process from from everything and seems to have done the trick :) i suspect it may cause some other problem im unaware of?

    now that it seesm ive created a fork is there anyway to cancel a fork already in process?

    thanks rich