This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA] Don't immediately SIGTERM the child of "target remote |".


On Sun, Nov 27, 2011 at 2:23 PM, Doug Evans <dje@google.com> wrote:
> On Sun, Nov 27, 2011 at 12:40 PM, Jan Kratochvil
> <jan.kratochvil@redhat.com> wrote:
>> On Thu, 24 Nov 2011 01:00:51 +0100, Doug Evans wrote:
>> [...]
>>> - ? ? ?int status;
>>> - ? ? ?kill (state->pid, SIGTERM);
>>> + ? ? ?int rc, status;
>>> + ? ? ?void (*ofunc) (); ? ? ?/* Previous SIGALRM handler. ?*/
>> ? ? ? ? ? ? ? ? ? ? ? ?^int (or void)
>>> +
>>> + ? ? ?/* Don't kill the task right away, give it a chance to shut down cleanly.
>>> + ? ? ?But don't wait forever though. ?*/
>>> +#if defined (HAVE_SIGACTION) && defined (SA_RESTART)
>>> + ? ? ?{
>>> + ? ? struct sigaction sa, osa;
>>> + ? ? sa.sa_handler = sigalrm_handler;
>>> + ? ? sigemptyset (&sa.sa_mask);
>>> + ? ? sa.sa_flags = 0;
>>> + ? ? sigaction (SIGALRM, &sa, &osa);
>>> + ? ? ofunc = osa.sa_handler;
>>> + ? ? ?}
>>> +#else
>>> + ? ? ?ofunc = (void (*)()) signal (SIGALRM, sigalrm_handler);
>>> +#endif
>> [...]
>>> + ? ? ?alarm (0);
>>> + ? ? ?signal (SIGALRM, ofunc);
>>
>> You should restore OSA, not just OFUNC.
>
> The code was borrowed from remote-sim.c.
> In this case I suspect it doesn't matter, but it's just as well to restore osa.
>

I will check this in on Monday if there are no objections.

2011-12-01  Doug Evans  <dje@google.com>

        * defs.h (wait_to_die_with_timeout): Declare.
        * utils.c: #include "gdb_wait.h".
        (sigalrm_handler, wait_to_die_with_timeout): New functions.
        * ser-pipe.c: Don't #include "gdb_wait.h".
        (pipe_close): Give child a chance to die on its own after closing
        its stdin before SIGTERM'ing it.

Attachment: gdb-111201-ser-pipe-sigterm-2.patch.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]