implement openpty mode. do not create child process, instead, open a pty, and output the slave name of pty device. used in gdb debugging. utilize this gdb command line option: --tty=TTY Use TTY for input/output by the program being debugged. $ OPENPTY= konsole /dev/pty1 echo hello >/dev/pty1 gdb --tty=/dev/pty1 emacs run mintty implementation https://github.com/xu-chiheng/mintty/commit/f0e80e1876502a83c8e5d1b5c24a4c714a0b0e18 konsole implemention on v4.9.4 https://github.com/xu-chiheng/konsole/commit/f7b94b0756101239279630d06309128d508aaf4f
use --openpty to activate openpty mode konsole --openpty /dev/pty1
IIUC, something similar can be achieved via: konsole --noclose -e /usr/bin/tty
(In reply to ninjalj from comment #2) > IIUC, something similar can be achieved via: > > konsole --noclose -e /usr/bin/tty A human can copy and past such slave name of the pty. How a program, like IDE(Eclipse CDT) get that slave name? The only way is through stdout. https://gitlab.gnome.org/GNOME/gnome-terminal/-/issues/7951 https://github.com/mintty/mintty/issues/1187
On Linux something like the following would output the tty device name. The sleep may need to be tweaked. die() { echo "$@" >&2 exit 1 } konsole --noclose -e /usr/bin/tty & konsolepid=$! sleep 1 for fd in /proc/$konsolepid/fd/* do [ "x$(readlink $fd)" = x"/dev/ptmx" ] && ptmx=$fd && break done [ -z $ptmx ] && die "konsole process doesn't appear to have opened a pty master" ptmx=${ptmx/fd/fdinfo} awk -F: '/tty-index/{ print "/dev/pts/"$2+0 }' $ptmx
Figured out a way to work partially: mintty.exe --hold always sh.exe -c "tty > 1.txt; read;" & konsole --no-close sh -e "tty > 1.txt; read;" & gnome-terminal --hold sh -e "tty > 1.txt; read;" & gdb --tty=$(cat 1.txt) emacs run But there is a problem that emacs can't get input from the terminal, because of the read command.
The 'read' is unnecessary. Try: konsole --hold -e 'sh -c /usr/bin/tty > konstty' (in konsole, --hold and --noclose are synonyms) and then: gdb --tty $(cat konstty) --args emacs -nw At the gdb prompt type "run" and you should be set to go.
Sorry, that should have been: konsole --hold -e 'sh -c "/usr/bin/tty > konstty"'
(In reply to ninjalj from comment #7) > Sorry, that should have been: > > konsole --hold -e 'sh -c "/usr/bin/tty > konstty"' Have you tried that ? On windows using mintty, this method does not work perfectly. sometimes the program(emacs) does not respond.
I'm trying this with 'mintty -Rt -h alw sleep 99999 &' and running gdb with another screen program (text editor mined) and see no problems.
(In reply to chiheng.xu from comment #8) > (In reply to ninjalj from comment #7) > > Sorry, that should have been: > > > > konsole --hold -e 'sh -c "/usr/bin/tty > konstty"' > > Have you tried that ? On windows using mintty, this method does not work > perfectly. > sometimes the program(emacs) does not respond. I don't use windows. With this method, you will need to wait for konsole/mintty to open the pty pair and execute 'sh -c "/usr/bin/tty > konstty"'. E.g: you could remove the "konstty" file, and wait for it to have a valid terminal name. On my testing, I have not seen any problem debugging emacs. Note that there may be unavoidable problems with SIGINT, see https://lwn.net/Articles/909496/