You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
macOS: work around freeze: don't suspend 'sleep' on interactive
Steps to reproduce:
1. sleep 3
2. press Ctrl+Z before it finishes (sleep builtin is forked into
its own process and suspended)
3. fg
sleep should resume and terminate, but instead, the forked sleep
builtin freezes, consuming 100% CPU. Only SIGKILL (kill -9) will
terminate it, although it can still be suspended again.
This is reproducible on (at least) macOS 12.7.6 arm64. I can also
reproduce this on 93u+ 2012-08-01 and on ksh2020.
It looks like this is a bug in macOS. When I compile ksh with ASan,
and the forked/resumed ksh sleep process hangs, and I simulate a
segfault by doing kill -s SEGV (the PID of the hanging process),
then the stack trace shows that it was hanging in the nanosleep
function of libsystem_c.dylib.
src/cmd/ksh93/bltins/sleep.c: sh_delay():
- Make it impossible to suspend the sleep builtin on macOS by
ignoring SIGTSTP. We only need to do that if we've invoked
'sleep' from the interactive prompt, i.e., if the SH_INTERACTIVE
state bit is active. (See 48ba696, d11d4c7)
Resolves: #814
0 commit comments