This is a regression that came with the TOCTOU race fix in kern_sig.c 1.216:
https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sys/kern/kern_sig.c#rev1.216
Reverting that file to 1.215 and /sys/sys/signalvar.h to 1.28 makes this
phenomenon go away.
Consider the following session on amd64 current:
$ cat > prog.c
int
main(void)
{
return 0;
}
$ cc -g prog.c
$ gdb -q a.out
(gdb) start
Breakpoint 1 at 0x52d: file prog.c, line 4.
Starting program: /tmp/a.out
Breakpoint 1 at 0x6e978d0052d: file prog.c, line 4.
main () at prog.c:4
4 return 0;
Current language: auto; currently minimal
(gdb) q
The program is running. Exit anyway? (y or n) y
Now gdb just hangs there and does nothing instead of exiting as
expected. It doesn't react to ^C but one can easily kill it with
^Z and then kill %%.
Here's the end of ktrace of that session (ended after a few seconds
with ^Z and kill %%):
67153 gdb 1521448750.813660 GIO fd 1 wrote 47 bytes
"The program is running. Exit anyway? (y or n) "
67153 gdb 1521448750.813672 RET write 47/0x2f
67153 gdb 1521448750.813678 CALL fstat(0,0x7f7ffffdc400)
67153 gdb 1521448750.813689 STRU struct stat { dev=1040, ino=78463,
mode=crw--w---- , nlink=1, uid=1000<"theo">, gid=4<"tty">, rdev=1285,
atime=1521448750<"Mar 19 09:39:10 2018">.807154547, mtime=1521448750<"Mar 19
09:39:10 2018">.807154547, ctime=1521448750<"Mar 19 09:39:10 2018">.807154547,
size=0, blocks=0, blksize=65536, flags=0x0, gen=0x0 }
67153 gdb 1521448750.813696 RET fstat 0
67153 gdb 1521448750.813702 CALL
mmap(0,0x10000,0x3<PROT_READ|PROT_WRITE>,0x1002<MAP_PRIVATE|MAP_ANON>,-1,0)
67153 gdb 1521448750.813724 RET mmap 19305116499968/0x118ed29c8000
67153 gdb 1521448750.814022 CALL fcntl(0,F_ISATTY)
67153 gdb 1521448750.814033 RET fcntl 1
67153 gdb 1521448750.814041 CALL read(0,0x118ed29c8000,0x10000)
67153 gdb 1521448752.475069 GIO fd 0 read 2 bytes
"y
"
67153 gdb 1521448752.475089 RET read 2
67153 gdb 1521448752.475099 CALL sigprocmask(SIG_BLOCK,0<>)
67153 gdb 1521448752.475108 RET sigprocmask 0<>
67153 gdb 1521448752.475118 CALL ptrace(PT_KILL,13232,0,0)
67153 gdb 1521448752.475130 RET ptrace 0
67153 gdb 1521448752.475137 CALL wait4(13232,0x7f7ffffdc4cc,0<>,0)
67153 gdb 1521448752.475160 RET wait4 13232/0x33b0
67153 gdb 1521448752.475164 CALL wait4(13232,0x7f7ffffdc494,0<>,0)
67153 gdb 1521448761.561842 PSIG SIGTERM SIG_DFL
13232 a.out 1521448761.561954 PSIG SIGHUP SIG_DFL