On Sun, 2003-02-23 at 10:46, Jim Morrison [Mailing-Lists] wrote:
> Having spent the w/e getting to grips with startup.pl's and the such I'm
> beginning to discover that it's only possible to share read-only memory
> and as soon as you write to memory it splits off.. .. 

The situation with forked Apache processes is the same as with any
forked process: you have to use some form of IPC to communicate between
them.

I suggest you look at IPC::MM or IPC::Shareable.  IPC::Shareable is more
transparent, but IPC::MM has better performance.  IPC::MM simply creates
a hash in shared memory and lets you write to it.  Either of these will
allow you to share data between processes.

> What I really want to do is to write a module that can be accessed from
> any of the child apache processes such that some work can be done at one
> stage, and if the second request comes through to another child, that
> child can pick up on the work of the first..

That sounds pretty sketchy to me.  Why are you trying to do that?  There
may be a much simpler way to achieve what you're after.

> Is there _absolutely_ no way that two children could ever have write
> access to the same object?

No, not when there are multiple processes involved.  The sharing that
happens with the modules I mentioned above involves serializing Perl
data into a byte stream, putting it into shared memory, and then pulling
it back and de-serializing on the other side.

> Lastly, coming from a RiscOS background, it was always possible to issue
> module interrupts such that one program can call the functions of
> another completely separate program..

You have the basic Unix building blocks here: signals, semaphores,
shared memory, sockets.

> It seems to me I'm missing some pretty basic inter-program communication
> stuff.. but then all my experience of calling one linux prog from
> another has usually worked by piping something from one to another.

You can talk between processes on STDIN (which is what a pipe is doing)
if the process you want to talk to is listening on STDIN.  Web server
processes don't do that.  They listen on sockets for requests from
outside.

- Perrin

Reply via email to