Ok I did get that working but not in pure perl.

I put a system("nohup $process > /dev/null 2>&1 &");
instead of all the fork and setsid



On 13 July 2011 20:07, Shlomi Fish <shlo...@shlomifish.org> wrote:

> Hi Ram,
>
> On Wed, 13 Jul 2011 19:02:46 +0530
> Ramprasad Prasad <ramprasad...@gmail.com> wrote:
>
> > I am trying a http API that would fork a background script and
> immediately
> > return
> >
> > I tried using fork() and setsid() or using Proc::Background
> > But the problem is my API hangs until the background script is complete
> >
> >
> > Is there a way I can avoid this
> >
> >
> > My code is here ( uses both fork and background  .. neither works :-( )
> >
> >
> > #!/usr/bin/perl
> > #
> > #
> > use strict;
> > use CGI;
> > use Proc::Background;
> >
> > $process = "/path/script";    #
>
> This will not compile with "use strict;" above. You need to add a "my". So
> I
> guess your code fails previously.
>
> > print "Content-Type: text/plain\n\n";
>
> Please use CGI.pm's ->header() function for that.
>
> > $SIG{CHLD}='IGNORE';
> > my $pid = fork();
> > setsid();
>
> I don't think you should call setsid() in both the parent *and* child.
>
> > print "STARTED\n";
> > exit if($pid);
> > my $proc1 = Proc::Background->new($process);
>
> What's going on here?
>
> > exit 0;
> >
>
> Regards,
>
>        Shlomi Fish
>
> --
> -----------------------------------------------------------------
> Shlomi Fish       http://www.shlomifish.org/
> Chuck Norris/etc. Facts - http://www.shlomifish.org/humour/bits/facts/
>
> Bill Gates, CEO of Microsoft decides to use Richard Stallman’s Emacs as the
> basis of his company’s state‐of‐the‐art product Microsoft Editing Macros™
> Enterprise Edition XP .NET Professional.
>
> Please reply to list if it's a mailing list post - http://shlom.in/reply .
>



-- 
Thanks
Ram
  <http://www.netcore.co.in/>




n <http://pragatee.com>

Reply via email to