When using zsh as the shell and a command that forks in ~/.zshenv, like `/bin/echo` here (plain `echo` is the shell builtin, which doesn't fork): $ cat ~/.zshenv echo Before /bin/echo Hello echo After ... gdbserver hangs at startup $ SHELL=zsh ./gdbserver localhost:9000 /bin/ls Before Hello <hangs here> Note that when using a similar bash feature, the BASH_ENV environment variable, it doesn't hang: $ SHELL=bash BASH_ENV=~/.zshenv ./gdbserver localhost:9000 /bin/ls Before Hello After Process /bin/ls created; pid = 745096 Listening on port 9000 It's also possible that the issue is in zsh, but I haven't dug enough to understand what's happening exactly.
I had the same problem with tcsh. It seems that gdbserver hangs in sigsuspend() and wait for SIGTRAP.
fish shell is also seeing this - see https://github.com/fish-shell/fish-shell/issues/7957 My investigation got as far as follows: gdbserver forks in preparation for exec'ing the shell. Before exec, it requests ptrace on itself (in `linux_ptrace_fun`). This causes signals to be delivered to gdbserver before the inferior shell; however gdbserver does not then arrange for the signal to be delivered to the shell so it is dropped. fish (and presumably zsh) relies on SIGCHLD to reap processes, so fish ends up hanging.
Encountered this downstream: https://github.com/Gallopsled/pwntools/issues/2377 workaround: https://github.com/Gallopsled/pwntools/pull/2378 https://github.com/Gallopsled/pwntools/pull/2321 which links: https://github.com/Gallopsled/pwntools/issues/2030 https://github.com/Gallopsled/pwntools/issues/2060 https://github.com/cvanloo/rop/blob/ec10a12e3256344e38e4c745781962f5245f5715/README.md?plain=1#L481