aboutsummaryrefslogtreecommitdiff
path: root/gdb/posix-hdep.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2022-12-05 11:15:09 -0700
committerTom Tromey <tromey@adacore.com>2022-12-13 12:51:53 -0700
commitc1dc47f53cccf633f3079db25a5b41adaee940a8 (patch)
treebdb940e44ce7ef19ab04332f559cae02a730edb8 /gdb/posix-hdep.c
parentd2f803afd5a3ae16933a3adb8dca9b16a01551ce (diff)
downloadfsf-binutils-gdb-c1dc47f53cccf633f3079db25a5b41adaee940a8.zip
fsf-binutils-gdb-c1dc47f53cccf633f3079db25a5b41adaee940a8.tar.gz
fsf-binutils-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/posix-hdep.c')
-rw-r--r--gdb/posix-hdep.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/gdb/posix-hdep.c b/gdb/posix-hdep.c
index 3d44338..2621197 100644
--- a/gdb/posix-hdep.c
+++ b/gdb/posix-hdep.c
@@ -19,8 +19,8 @@
#include "defs.h"
#include "gdbsupport/event-loop.h"
-
#include "gdbsupport/gdb_select.h"
+#include "inferior.h"
/* Wrapper for select. Nothing special needed on POSIX platforms. */
@@ -38,3 +38,21 @@ gdb_console_fputs (const char *buf, FILE *f)
{
return 0;
}
+
+/* See inferior.h. */
+
+tribool
+sharing_input_terminal (int pid)
+{
+ /* Using host-dependent code here is fine, because the
+ child_terminal_foo functions are meant to be used by child/native
+ targets. */
+#if defined (__linux__) || defined (__sun__)
+ char buf[100];
+
+ xsnprintf (buf, sizeof (buf), "/proc/%d/fd/0", pid);
+ return is_gdb_terminal (buf);
+#else
+ return TRIBOOL_UNKNOWN;
+#endif
+}