This is the mail archive of the gdb@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]

Re: invoking GDB from FE and signals


Andreas Schwab <schwab@suse.de> writes:
> Bob Rossi <bob_rossi@cox.net> writes:
>
>> I find in emacs:process.c code that they send the SIGINT in different
>> ways
>>     /* If possible, send signals to the entire pgrp
>>        by sending an input character to it.  */
>>
>>     /* TERMIOS is the latest and bestest, and seems most likely to
>>        work.  If the system has it, use it.  */
>>     case SIGINT:
>>       sig_char = &t.c_cc[VINTR];
>>       break;
>>     ...
>>     send_process (proc, sig_char, 1, Qnil);
>
> This part is only active if SIGNALS_VIA_CHARACTERS is defined.  That is
> defined mostly for BSD-derived systems, but not, for example, for Linux.
> The fallback is to send the signal to the foreground process group of the
> terminal.

Do you know why they prefer that approach on Linux?  There are race
conditions doing it either way, but the SIGNALS_VIA_CHARACTERS one
seems less likely:

- If SIGNALS_VIA_CHARACTERS is #defined, then we get the tty's "intr"
  character and send that.  The race is that the child could change
  its "intr" character between the time we fetch it and the time the
  tty processes the one we've sent.

- Otherwise, we get the tty's controlling process group with
  tcgetpgrp, and then use killpg to send that process group the signal
  we want.  The race is that the child could change its process group
  between the time we fetch it and the time we send it.

A shell changes the terminal's process group every time it runs a
command.


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