Re: How to redirect "Segmentation fault (core dumped)" to err.txt?

From: Pascal Bourguignon (spam_at_mouse-potato.com)
Date: 12/07/04


Date: 07 Dec 2004 07:00:48 +0100


"Alex Vinokur" <alexvn@big-foot.com> writes:
> $ ( ./a ; true ) 2> err
>
> But 'err' doesn't contain "Segmentation fault (core dumped)".

Of course, what do you expect? the segmentation fault is reported as status!
If you want that message, you should write it like this:

( ./a ; if [ $? = $(( 128 + 11 )) ] ; then \
    echo "Segmentation fault" 1>&2 ; fi ) 2> err

Whether the core was dumped or not would depend on the executable ./a
and how it configured that signal handling.

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
The world will now reboot; don't bother saving your artefacts.


Relevant Pages