dan wrote:
Hi

Hello,

I've written a perl program which, when executed, fork()'s into the
background, doing it's job, so that the ssh session which executed it can be
closed.
The dilemma I have is the program crashes on random occasions due to an
unknown bug which I can't trace.

Maybe it's a Heisenbug?  http://en.wikipedia.org/wiki/Heisenbug

The only method I would have of catching
the bug is to execute it in an ssh terminal and leave it open until it
crashes (which could be hours, days, or weeks). My connection's not the
stablest in the world, so this session may end up being prematurely
disconnected, and I'd still lose the output.
Is there a way or saying that every STDOUT, STDERR, die(), exit(), and any
error messages can be appended to a specified logfile, so I can maybe track
this bug? I've done a search on google for logging STDOUT and things, most
results of which give me modules which I don't really understand how it
would work.
Could anyone simply this for me, or give me any suggestions for things to
try/do/write to make this possible?

You could try this (untested):

BEGIN {
    my $log_file = ;
    open STDOUT, '>', '/some/dir/logfile' or die "Cannot redirect STDOUT: $!";
    open STDERR, ">&STDOUT"               or die "Cannot dup STDOUT: $!";
    }



John
--
use Perl;
program
fulfillment

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to