apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject Re: no replacement for ap_spawn_child's functionality?
Date Fri, 23 Nov 2001 19:07:25 GMT
Ryan Bloom wrote:

> On Friday 23 November 2001 10:06 am, Stas Bekman wrote:
> 
>>Ryan Bloom wrote:
>>
>>>On Friday 23 November 2001 12:25 am, Stas Bekman wrote:
>>>
>>>>I'm porting Apache::SubProcess Perl/XS module to mod_perl 2.0 and after
>>>>checking the existing APR's API I have found that the functionality
>>>>existing in ap_spawn_child from 1.3.x has gone. Now you can only run a
>>>>program/script from the spawned process.
>>>>
>>>>Any reason for removing this support? I'm probably not aware of some
>>>>hidden portablity issues, but by comparing ap_spawn_child from 1.3.x
>>>>with apr_proc_create() from APR isn't the change is as simple as
>>>>replacing execve() call with func() call after copying apr_proc_create()
>>>>into some different function (of course the args should be different)?
>>>>
>>>Windows doesn't support creating a new process without running a new
>>>program.  I have been looking at creating fork() on Windows, but it is
>>>incredibly non-trivial.
>>>
>>so how is this solved in 1.3.x? Or is it not used for portable modules?
>>I see (grep) that at least mod_rewrite and http_log use it in core.
>>
> 
> Take a look at the implementation of spawn_child_core on Windows though.
> It isn't actually creating a new process.  Near as I can tell, it is doing all of
> the work in a thread from the original process.  I can't find where the thread
> is created, but we also don't have any function to create a new process.

Can we do the same workaround for apr? it was very slick to be able to 
pass a function to run to a spawned child and not to worry about IO 
pipes setup, exec_cleanup, etc. Now people will have to code their own 
fork() with a bunch of other things, and make things not very portable 
:( APR already includes a lot of OS specific code surrounding fork() 
code, it'd be really a pity not to be able to use this knowledge.

I was also thinking to ask this: Is it possible to have some wrapper 
that will exec a process (and a func on my list) either in a spawned 
process or in a thread. e.g. if we running in the threaded env, the 
thread will be used to run the process, if we are in pre-fork run in the 
sub-process? The point is to hide all the complexity from the user code. 
You realize that if user writes his code to spawn a thread for doing 
some stuff it won't work with pre-fork and vice versa. What's apr take 
on this? I've read through all the .h files but couldn't find anything 
like this.


_____________________________________________________________________
Stas Bekman             JAm_pH      --   Just Another mod_perl Hacker
http://stason.org/      mod_perl Guide   http://perl.apache.org/guide
mailto:stas@stason.org  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/



Mime
View raw message