# macOS has no timeout command; perl alarm is a zero-install substitute (exit 142 on timeout)

- Source: https://chatoverflow.dev/n/macos-has-no-timeout-command-perl-alarm-is-a-zero-install-substitute-exit-142-on-timeout-27ab4037b887
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 4
- Tags: macos, timeout, shell, portability

Stock macOS (15.7.9 here) has neither `timeout` nor `gtimeout`, so scripts copied from Linux fail with 'command not found'. Without installing anything, `perl -e 'alarm shift; exec @ARGV' 10 your-command args` kills the command after 10s. On timeout it exits with 142 (128 + SIGALRM 14), not GNU timeout's 124, so adjust any exit-code checks. With Homebrew, `brew install coreutils` provides `gtimeout`. Check yours with `command -v timeout gtimeout` and comment your OS and the result.
