diff options
author | Tom Tromey <tromey@adacore.com> | 2022-12-05 11:15:09 -0700 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2022-12-13 12:51:53 -0700 |
commit | c1dc47f53cccf633f3079db25a5b41adaee940a8 (patch) | |
tree | bdb940e44ce7ef19ab04332f559cae02a730edb8 /gdb/mingw-hdep.c | |
parent | d2f803afd5a3ae16933a3adb8dca9b16a01551ce (diff) | |
download | gdb-c1dc47f53cccf633f3079db25a5b41adaee940a8.zip gdb-c1dc47f53cccf633f3079db25a5b41adaee940a8.tar.gz gdb-c1dc47f53cccf633f3079db25a5b41adaee940a8.tar.bz2 |
Refactor code to check for terminal sharing
This refactors the code to check for terminal sharing.
is_gdb_terminal is exported, and sharing_input_terminal_1 is renamed,
slightly refactored, and moved to posix-hdep.c. A new
Windows-specific implementation of this function is added to
mingw-hdep.c.
MSDN has a warning about GetConsoleProcessList
This API is not recommended and does not have a virtual terminal
equivalent. [...] Applications remoting via cross-platform
utilities and transports like SSH may not work as expected if
using this API.
However, we believe this isn't likely to be an issue for gdb.
Diffstat (limited to 'gdb/mingw-hdep.c')
-rw-r--r-- | gdb/mingw-hdep.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/gdb/mingw-hdep.c b/gdb/mingw-hdep.c index 651e795..9d0337c 100644 --- a/gdb/mingw-hdep.c +++ b/gdb/mingw-hdep.c @@ -21,8 +21,8 @@ #include "main.h" #include "serial.h" #include "gdbsupport/event-loop.h" - #include "gdbsupport/gdb_select.h" +#include "inferior.h" #include <windows.h> @@ -371,3 +371,32 @@ gdb_console_fputs (const char *linebuf, FILE *fstream) last_style = style; return 1; } + +/* See inferior.h. */ + +tribool +sharing_input_terminal (int pid) +{ + std::vector<DWORD> results (10); + DWORD len = 0; + while (true) + { + len = GetConsoleProcessList (results.data (), results.size ()); + /* Note that LEN == 0 is a failure, but we can treat it the same + as a "no". */ + if (len < results.size ()) + break; + + results.resize (len); + } + /* In case the vector was too big. */ + results.resize (len); + if (std::find (results.begin (), results.end (), pid) != results.end ()) + { + /* The pid is in the list sharing the console, so don't + interrupt the inferior -- it will get the signal itself. */ + return TRIBOOL_TRUE; + } + + return TRIBOOL_FALSE; +} |