It seems in my environment (Linux On Power) there are issues when I try to run a linux command in gdb. Using less
prints the whole file to stdout rather than running less
. Vim tells me the output is not a terminal. Spawning a new xterm window in gdb is linked to the gdb process and closes when I close gdb.
gdb version:
: gdb --version
GNU gdb (GDB) Red Hat Enterprise Linux 8.2-19.el8
I tried doing the following:
(gdb) !less some_file.txt
Rather than opening the file up in the less
process, it just prints the whole file to stdout.
If I use vim in gdb, I get the following message:
(gdb) !vim some_file.txt
Vim: Warning: Output is not to a terminal
But after a couple of seconds, it will open vim up and allow me to navigate through the file.
One final weird thing that hasn't happened before that might be a hint to what is going on. I use xterm. So let's say I open up a new xterm window in gdb:
(gdb) !xterm &
A new window pops up. Now let's say I quit gdb:
(gdb) q
A debugging session is active.
Inferior 1 [process 1027212] will be killed.
Quit anyway? (y or n) y
When I hit y
, it will stay stuck like that until I either close the new xterm window, or I hit Control-C. If I hit Control-C, gdb terminates, but then the new xterm window closes.
So it seems somehow the processes that are being spawned in gdb aren't behaving correctly.
Apparently this behavior occurs when piping gdb to a file with tee
. I had not noticed it initially because I was calling gdb from a script, obfuscating the pipe to tee
. Thanks to @Andrew and @Barmar for helping me sort this out.