This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFC/PATCH] New convenience variable $_exitsignal
- From: Tom Tromey <tromey at redhat dot com>
- To: Sergio Durigan Junior <sergiodj at redhat dot com>
- Cc: "Pierre Muller" <pierre dot muller at ics-cnrs dot unistra dot fr>, "'GDB Patches'" <gdb-patches at sourceware dot org>
- Date: Thu, 18 Jul 2013 10:48:41 -0600
- Subject: Re: [RFC/PATCH] New convenience variable $_exitsignal
- References: <m3mwqqvagk dot fsf at redhat dot com> <00db01ce6b24$0b716aa0$22543fe0$ at muller@ics-cnrs.unistra.fr> <m3zjuotykn dot fsf at redhat dot com>
>>>>> "Sergio" == Sergio Durigan Junior <sergiodj@redhat.com> writes:
Sergio> To the extent of my knowledge, this is a shell feature. It sets $? (the
Sergio> variable which contains the exit code of the program) to 128 + signal
Sergio> number.
No, it's actually how things work under the hood.
When you call 'wait' (or one of its many equivalent APIs), the result
you get is an integer that encodes whether the program exited normally
or via signal; if normally, the exit code; or if via signal, which signal.
This touches on Doug's question of how to use these variables
generically. There's no nice way for a script to use this right now,
partly because gdb's scripting is so limited, but also because the two
values are put into two separate variables.
Just having a variable that is "the exit status as the OS reports it"
seems nice, but then it means reimplementing WIFEXITED and friends. Not
perhaps the friendliest.
Tom