On Saturday 20 February 2010 21:24:31 Cosimo Streppone wrote:
> That's really valuable, thanks for sharing.
> However, a question:
> 
> is this something that should be included in Apache2::SubProcess
> to make it better? Or is this something that could be published
> another, separate, CPAN distribution?
> Or maybe it's already out there?
> 
Apache2::SubProcess' purpose is more for creating processes similar to CGI-
scripts. A CGI-script is killed by apache if it does not produce output for a 
certain period of time. Also, the process gets killed I think at the end of 
the request.

I think it could be an Apache2::SubProcess extension. That would mean adding 
the stuff to xs/Apache2/SubProcess/SubProcess_pm in the source tree. But there 
are a few things that are unsolved:

- is there a portable way to get all open file descriptors of the current 
process? Under Linux one can readdir(/proc/self/fd). On Darwin I once simply 
closed all fds from 0 to 1000. Some systems have getdtablesize(2), sometimes 
it is getrlimit. Sometimes you can open /dev/something or /proc/self/something 
and read the descriptor table at a certain offset. What the module should do 
on Windows I simply don't know.

If you can solve this problem with apr-functions I think the it can really be 
in Apache2::SubProcess.

- a way of really restoring the perl environment would be good, so that you 
really can fork off subroutines.

But the real reason why it is not shaped out as a separate module yet is that 
the code is really old and quite seldom needed. The main part was written 
around year 2000 for mp1. At that time I didn't know about POSIX::close and 
thus invented my own version like:

  sub SYS_close {6;}            # works on Linux and Darwin
  sub sysclose {
    syscall &SYS_close, shift()+0;
  }

In short, the code was ugly.

And because my solution is Linux-only.

Torsten

Reply via email to