in reply to Child reading from Parent

Just use a file. It's by far the simplest way to share data. Have your child process check the -M time on a "stop" file to exit if it was touched after the process was forked.

Replies are listed 'Best First'.
Re: Re: Child reading from Parent
by steves (Curate) on Feb 20, 2003 at 00:12 UTC

    As a simple flag, a file may work but I'm not crazy about that one. If someone else touches it they affect the process ... Files, in general, make poor IPC choices. For a simple flag, pick a semaphore model. Depends on your platform which one fits -- I'm only familiar with the UNIX System V semapahores but have not used them from Perl. A signal can be used as a semaphore, but that also keeps me awake at night. It's asynchronous which means that anything called from the handler has to be reentrant. You can sometimes get away with setting a global flag and checking it in your main loop in a pinch though. Again, I have not done any of that in Perl so just ideas ...

      I'm not sure what your statement about files making a poor IPC choice is based on. I consider the ability to stop the process by touching the file a feature.

      Files are simple and portable, and don't require a lot of extra modules to be compiled. This monk stated he is on Windows, so his options are limited, especially if he cares about being cross-platform.

        I meant in general. Without locking there's no synchronization. And their availability to the rest of the world can be viewed as a feature or a downside depending on the problem being solved. I can tell you from experience that they do not scale well for large systems. That doesn't mean they aren't right here. Just offering a point of view ...