in reply to Problem writing to file from a daemon

Not clear about your actual situation, but the following code does prove that child processes being forked would be aware of the files opened by parents. But when to close is a little bit tricky, the sync stuff.
use strict; my $file; open($file, ">abc"); my $ret = fork; if ($ret) { print $file "log from parent\n"; sleep(5); close($file); } else { print $file "log from child\n"; }

Replies are listed 'Best First'.
When to close
by peschkaj (Pilgrim) on Nov 11, 2002 at 19:26 UTC

    I solved the problem of when to close by trapping for close signals from the terminal (kill -1, kill -9) and including close handles in the event handler.

    If you make something idiot-proof, eventually someone will make a better idiot.
    I am that better idiot.