When the OpenDebugAD7 input is closed, the program does not exit and instead stays alive doing nothing, which also keeps GDB and the debuggee alive.
Reproducer:
#!/bin/bash
# Usage: ./repro.sh /path/to/OpenDebugAD7
# Leaves the processes running. Kill OpenDebugAD7 afterwards.
send() { printf 'Content-Length: %d\r\n\r\n%s' ${#1} "$1"; }
{
send '{"seq":1,"type":"request","command":"initialize","arguments":{"adapterID":"cppdbg","pathFormat":"path"}}'
send '{"seq":2,"type":"request","command":"launch","arguments":{"program":"/bin/sleep","args":["12345"],"cwd":"/","MIMode":"gdb"}}'
send '{"seq":3,"type":"request","command":"configurationDone"}'
sleep 5
} | "$1" &> /dev/null &
sleep 15
pgrep -a -x OpenDebugAD7;
pgrep -a -x gdb;
pgrep -a -f 'sleep 12345'
This is because the remaining threads are treated as foreground threads, and so keep the program alive. One solution is to mark them as background threads. Another is to handle closed input as if the user had sent a disconnect request.
When the OpenDebugAD7 input is closed, the program does not exit and instead stays alive doing nothing, which also keeps GDB and the debuggee alive.
Reproducer:
This is because the remaining threads are treated as foreground threads, and so keep the program alive. One solution is to mark them as background threads. Another is to handle closed input as if the user had sent a disconnect request.