http://qs1969.pair.com?node_id=123102

deprecated has asked for the wisdom of the Perl Monks concerning the following question:

I've got a rather large (~1000 lines) program that runs continually. However, it is "event driven" and doesnt actually do anything until it getts a specific kind of input, or I prod it in some fashion. I have lately been wanting to include a sort of "memo" or "reminder" function into it.

I figure it would require forking off a sub that wasnt event driven. In other words, a specific event would drive a fork in the middle of a sub that was _not_ event driven, like so:

sub non_event_driven { if (fork()) { # i'm the parent! return 1; } else { # i'm the child! for (;;) if (time() == $waiting_epoch) { # ta-da! play an mp3 and wake up our user # or whatever exit 0; # safe for shell, and we're done anyways } } } return 0; }
the problem is, since fork() creates a _copy_ of the program youre running, and your current program is 50mb in memory, you could *seriously* hurt the host machine if you had, say, twenty of them running... as I might well do with a reminder sub.

any suggestions?

thanks,
brother dep

--
Laziness, Impatience, Hubris, and Generosity.