Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^8: How to find perl line after segfault.

by Steve_BZ (Chaplain)
on Feb 15, 2015 at 10:09 UTC ( [id://1116776]=note: print w/replies, xml ) Need Help??


in reply to Re^7: How to find perl line after segfault.
in thread How to find perl line after segfault.

Well I shall probably have to do that, But then when it segfaults I wont be able to manage the crash, It'll just be a case of restarting the application. I suppose since I have a crash file (the trace.txt), I can look for trace.txt files at the startup of a programme and then do whatever I need to.

Regards

Steve.

  • Comment on Re^8: How to find perl line after segfault.

Replies are listed 'Best First'.
Re^9: How to find perl line after segfault.
by BrowserUk (Patriarch) on Feb 15, 2015 at 10:58 UTC
    But then when it segfaults I wont be able to manage the crash,

    It would be no different if you used open3(). That also starts a separate process over which you would have no control.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
    In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked

      Well, with open3(), I can use waitpid and then read (error); which allows me some control over what happens next, if I just did

      system ("perl -d:CallTrace Foo.pl");

      Wouldn't it just crash? Maybe not, I should probably try it.

      Regards

      Steve.

        Well, with open3(), I can use waitpid and then read (error); which allows me some control over what happens next, if I just did system ("perl -d:CallTrace Foo.pl"); Wouldn't it just crash?

        It will crash either way, the only differences is that with Re: Catching errors (II)., you can get the error code (and, on *nix at least, the 'signal value'); and then read the output from stderr.

        If you use my suggested system q[perl -d:CallTrace Foo.pl 2>trace.txt];, then you can also read back the stderr output, by reading the file.

        You're also more likely to get the last few lines, because you won't have the double-buffering effect you get when you use pipes.

        Also, if the exit code is important to you, then (from perldoc perlfunc system ):

        If you'd like to manually inspect system's failure, you can check all +possible failure modes by inspecting $? like this: if ($? == -1) { print "failed to execute: $!\n"; } elsif ($? & 127) { printf "child died with signal %d, %s coredump\n", ($? & 127), ($? & 128) ? 'with' : 'without'; } else { printf "child exited with value %d\n", $? >> 8; }

        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
        In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1116776]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2024-03-29 15:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found