unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#16745: Can't send SIGTSTP from Emacs through GDB
@ 2014-02-13 19:33 Barry OReilly
  2014-02-14  9:28 ` Andreas Schwab
  2014-02-14 13:11 ` Daimrod
  0 siblings, 2 replies; 4+ messages in thread
From: Barry OReilly @ 2014-02-13 19:33 UTC (permalink / raw)
  To: 16745

[-- Attachment #1: Type: text/plain, Size: 2272 bytes --]

When running GDB in Emacs and sending SIGTSTP via C-c C-z to another
Emacs ran under GDB, the Emacs under GDB does not appear to receive
the SIGTSTP.

Recipe:

  ./src/emacs -Q
  M-x gdb
  gdb -i=mi src/emacs
  run -Q
  C-c C-z
  [The Emacs under GDB is not stopped.]

However, when I run GDB from the shell rather than from Emacs:

  gdb src/emacs
  run -Q
  C-z
  [The Emacs under GDB stopped.]

I noticed src/.gdbinit has line:

  handle SIGTSTP nopass

So I tried with and without this to no effect.

When I run with these debug statements:

diff --git a/src/process.c b/src/process.c
index 85470b6..176de75 100644
--- a/src/process.c
+++ b/src/process.c
@@ -5753,6 +5753,9 @@ process_send_signal (Lisp_Object process, int signo,
Lisp_Object current_group,
 #else
          sig_char = &t.c_cc[VSUSP];
 #endif
+          { struct timespec debug_ts; char debug_dateStr[20]; {
clock_gettime(CLOCK_REALTIME, &debug_ts); struct tm mytm;
localtime_r(&debug_ts.tv_sec, &mytm); strftime(debug_dateStr, 20,
"%Y-%m-%dT%H:%M:%S", &mytm); }
+               printf( "%s.%09ld|pid:%d|tid:%ld|%s|%d| DEBUG:
sig_char=%02x\n", // TODO: debugging
+                                 debug_dateStr, debug_ts.tv_nsec,
getpid(), pthread_self(), __FILE__, __LINE__, *sig_char ); fflush(stdout); }
          break;
        }

@@ -5901,6 +5904,9 @@ traffic.  */)
 #ifndef SIGTSTP
   error ("No SIGTSTP support");
 #else
+  { struct timespec debug_ts; char debug_dateStr[20]; {
clock_gettime(CLOCK_REALTIME, &debug_ts); struct tm mytm;
localtime_r(&debug_ts.tv_sec, &mytm); strftime(debug_dateStr, 20,
"%Y-%m-%dT%H:%M:%S", &mytm); }
+       printf( "%s.%09ld|pid:%d|tid:%ld|%s|%d| DEBUG: Send SIGTSTP\n", //
TODO: debugging
+                         debug_dateStr, debug_ts.tv_nsec, getpid(),
pthread_self(), __FILE__, __LINE__ ); fflush(stdout); }
   process_send_signal (process, SIGTSTP, current_group, 0);
 #endif
   return process;

The output during the ill recipe is:

2014-02-13T14:11:49.438466000|pid:22430|tid:47532927609088|process.c|5909|
DEBUG: Send SIGTSTP
2014-02-13T14:11:49.438547000|pid:22430|tid:47532927609088|process.c|5758|
DEBUG: sig_char=1a

So the signal is being sent it seems. What might be the obstruction?

I am on RHEL 5, using latest Emacs from trunk and GDB 7.1.

[-- Attachment #2: Type: text/html, Size: 2600 bytes --]

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#16745: Can't send SIGTSTP from Emacs through GDB
  2014-02-13 19:33 bug#16745: Can't send SIGTSTP from Emacs through GDB Barry OReilly
@ 2014-02-14  9:28 ` Andreas Schwab
  2014-02-14 14:19   ` Barry OReilly
  2014-02-14 13:11 ` Daimrod
  1 sibling, 1 reply; 4+ messages in thread
From: Andreas Schwab @ 2014-02-14  9:28 UTC (permalink / raw)
  To: Barry OReilly; +Cc: 16745

Barry OReilly <gundaetiapo@gmail.com> writes:

> When running GDB in Emacs and sending SIGTSTP via C-c C-z to another
> Emacs ran under GDB, the Emacs under GDB does not appear to receive
> the SIGTSTP.
>
> Recipe:
>
>   ./src/emacs -Q
>   M-x gdb
>   gdb -i=mi src/emacs
>   run -Q
>   C-c C-z
>   [The Emacs under GDB is not stopped.]

Here the signal is sent to terminal process group associated with the
gdb command buffer, which includes the gdb process, but not the inferior
(which runs in its own pty).

> However, when I run GDB from the shell rather than from Emacs:
>
>   gdb src/emacs
>   run -Q
>   C-z
>   [The Emacs under GDB stopped.]

Here the terminal sends the signal to the foreground process group,
which includes the inferior (and not gdb).

This problem does not appear with the traditional gdb interface, since
it closely resembles the shell setup.  I recommend using gud-gdb
instead.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#16745: Can't send SIGTSTP from Emacs through GDB
  2014-02-13 19:33 bug#16745: Can't send SIGTSTP from Emacs through GDB Barry OReilly
  2014-02-14  9:28 ` Andreas Schwab
@ 2014-02-14 13:11 ` Daimrod
  1 sibling, 0 replies; 4+ messages in thread
From: Daimrod @ 2014-02-14 13:11 UTC (permalink / raw)
  To: Barry OReilly; +Cc: 16745

Barry OReilly <gundaetiapo@gmail.com> writes:
Hi,

> When running GDB in Emacs and sending SIGTSTP via C-c C-z to another
> Emacs ran under GDB, the Emacs under GDB does not appear to receive
> the SIGTSTP.
>
> Recipe:
>
>   ./src/emacs -Q
>   M-x gdb
>   gdb -i=mi src/emacs
>   run -Q
>   C-c C-z
>   [The Emacs under GDB is not stopped.]

I use the following workaround:
1. switch to the buffer *input/output of <program>*
2. C-q C-z RET

-- 
Daimrod/Greg





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#16745: Can't send SIGTSTP from Emacs through GDB
  2014-02-14  9:28 ` Andreas Schwab
@ 2014-02-14 14:19   ` Barry OReilly
  0 siblings, 0 replies; 4+ messages in thread
From: Barry OReilly @ 2014-02-14 14:19 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: 16745

[-- Attachment #1: Type: text/plain, Size: 141 bytes --]

Thanks, just tried gud-gdb and it works well. Actually, the windowing
behavior is saner than when using gdb, so I think I'll prefer gud-gdb.

[-- Attachment #2: Type: text/html, Size: 177 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-02-14 14:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-13 19:33 bug#16745: Can't send SIGTSTP from Emacs through GDB Barry OReilly
2014-02-14  9:28 ` Andreas Schwab
2014-02-14 14:19   ` Barry OReilly
2014-02-14 13:11 ` Daimrod

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).