You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Torsten Luettgert <t....@combox.de> on 2002/11/18 14:32:49 UTC

fork() and semaphores

Hi,

I'm using Embperl 1.3.4 with mod_perl 1.27 and apache 1.3 on linux 2.4.
Now I need to fork() in a page to spawn off a long-running process
(cdrecord, basically). I used the stuff from the mod_perl docs:

sub start_burning() {
   require POSIX;
   $SIG{CHLD} = 'IGNORE';
   defined (my $kid = fork) or die "Cannot fork: $!\n";
   return if $kid;

   chdir '/';
   $0 = 'burner-process';
   close STDOUT;
   close STDERR;
   close STDIN;
   POSIX::setsid();
   TEMA::secure_system('/usr/bin/cdrecord.wrap', $nn);
   CORE::exit(0);
}

never mind the secure_system stuff, it is basically
system { '/usr/bin/cdrecord.wrap' } '/usr/bin/cdrecord.wrap', $nn;

now this works fine, but after the first run, further accesses lock up.
Even restarting apache, every access will freeze up. I'm 99% sure that's
because the semaphore lock on the session isn't released, and now I'm
looking for a way to _really, absolutely_ detach the burner process from
the apache/embperl process.

I'm not too keen on writing a cdrecord daemon which listens on a unix
domain socket or anything, since that would be another point of failure.

Thanks for your help,
Torsten <t....@pressestimmen.de>


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: fork() and semaphores

Posted by "Luiz Fernando B. Ribeiro" <lu...@engenhosolucoes.com.br>.
Em 18 Nov 2002 14:32:49 +0100
Torsten Luettgert <t....@combox.de> escreveu:

> Hi,
> 
> I'm using Embperl 1.3.4 with mod_perl 1.27 and apache 1.3 on linux
> 2.4. Now I need to fork() in a page to spawn off a long-running
> process(cdrecord, basically). I used the stuff from the mod_perl docs:
> 

Hi,

Write your burning code in a script, call it with system and
then fork on the script. When the script returns after the fork your
apache proccess will go on without locking and you can take the time you
need as you expect.

This works form me without any problem.

Regards,

Luiz Fernando B. Ribeiro
Engenho Soluções para a Internet

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org