Jump to content

Code line when POSIX signal handler invoked?


mralston

Recommended Posts

Is it possible to find out what line of code a PHP script was processing immediately before it is interrupted upon receiving a POSIX signal?

 

A bit of background - I've got a PHP script which runs (from the command line) hundreds of thousands of times a day and usually it's just fine. Every so often (less than once a week) it gets into a muddle and freezes until I kill it.

 

I've written a signal handler (using the posix_signal() function) into the script which catches SIGABRT signals. When it gets one, it dumps $GLOBALS to a file, cleanly releases the data its working on then exits. That gives me a nice 'get out of jail free' card, but I'd really like to identify where (and then why) it's freezing.

 

I could insert loads of debugging code which sets some variable with what stage it's up to, but it's a fairly complicated script and I'd rather not. There's got to be a better way! __LINE__ and __FUNCTION__ unfortunately just point to my signal handler function.

 

So, is there anyway that the function which is invoked by the SIGABRT signal can report what line of code the script was on at the time the SIGABRT was received?

 

Or alternatively, is there a way to figure out what a running PHP script is doing if you know its PID? Maybe there's something in /proc/<PID> which might help me...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.