tags:

views:

103

answers:

2

I have written a Perl script that sends data to clients. It works some time (from one minute to 2 hours) and then goes down. No errors in console, no errors in log.

I added an END section to it - it isn't executed.

What can I do to figure out what the problem is?

+2  A: 

No errors in the log, but can you put more logging in to see where exactly it's failing? That is, log lines like:

00:00:00 In section 1
00:00:05 In section 2
...
00:09:28 In section 34

Then you can see what section last executed.

If it's really bugging you, you could also try stepping through in the Perl debugger and seeing if you can reproduce it. You could also try simplifying your script, removing various sections, etc. to see if you can really pinpoint the problem.

Hope that helps.

Chris Simmons
+1 for print statements. They are the best for debugging any code.
Oz
ok. I'll try it now.
Lexsys
+10  A: 

Since the script is writing data to clients, I would guess that its untimely death is due to an unhandled SIGPIPE. If that is the case, installing a signal handler for SIGPIPE is an easy way to verify it. Check out perlipc for details and examples on signal handlers in Perl.

bish
I was writing to a client, which sometimes closes a connection before I have send him all the data. So when he is on-line my script starts failing. Thank you for your advice.
Lexsys