trap(1) on Solnix vs Linux and the BSDs
On Solnix, trap is a shell built-in, not a separate binary, and the Solnix page documents it separately for sh, csh (as onintr), ksh and ksh93. The FreeBSD trap(1) page is only an index of shell built-ins and does not describe trap's behaviour, so a flag-by-flag comparison is not possible.
The manual pages
- Solnix: trap(1) from
pkgs.solnix.illumos-world-man· illumos.org - FreeBSD: trap(1) 15.1-RELEASE
What Solnix runs
A default Solnix system has no trap binary. The behaviour depends on which shell runs it: sh, ksh and ksh93 each have their own trap section, and csh uses onintr instead. Only the ksh93 trap documents an option (-p). No other variants are shipped.
Differences
| Compared with | Topic | What differs |
|---|---|---|
| FreeBSD | what the manual page covers | Solnix trap(1) describes how trap works in each shell. FreeBSD trap(1) is the builtin(1) index of shell built-ins and describes no trap semantics, so the bundle gives no FreeBSD trap behaviour to compare. Source: Solnix trap(1) DESCRIPTION; FreeBSD trap(1) NAME and DESCRIPTION |
| FreeBSD | which shells provide trap | The FreeBSD table lists trap as a built-in of sh(1) only, not csh(1), and not as a standalone utility. On Solnix, trap is in sh, ksh and ksh93, and csh uses onintr. FreeBSD lists onintr for csh(1) only. Source: FreeBSD trap(1) Commands table (trap, onintr rows); Solnix trap(1) SYNOPSIS |
| FreeBSD | -p option | Solnix ksh93 trap -p prints current traps in a form that can be fed back to the shell. The FreeBSD page documents no trap options, so the manual does not say whether FreeBSD sh has -p.Source: Solnix trap(1) ksh93 -p; FreeBSD trap(1) (no trap options documented) |
| FreeBSD | conditions beyond signals | Solnix ksh and ksh93 trap accept ERR and DEBUG. ksh93 also accepts KEYBD, and EXIT or 0 for exit. Solnix sh documents only signal numbers or names, with 0 for exit. The FreeBSD page lists no conditions, so the manual does not say what FreeBSD sh accepts. Source: Solnix trap(1) ksh, ksh93 and sh DESCRIPTION; FreeBSD trap(1) |
| FreeBSD | unknown condition and exit status | In Solnix ksh93, an unknown condition makes trap exit non-zero but does not terminate the invoking shell. ksh93 trap exits 0 on success and >0 on error. The FreeBSD page states no exit status for trap. Source: Solnix trap(1) ksh93 DESCRIPTION and exit values; FreeBSD trap(1) |
| FreeBSD | ignored-on-entry signals | On Solnix, setting a trap on a signal that was ignored on entry to the shell has no effect. In ksh93 this reports no error. The FreeBSD page does not say how its sh behaves. Source: Solnix trap(1) sh, ksh, ksh93 DESCRIPTION; FreeBSD trap(1) |
| Linux, OpenBSD, NetBSD | no counterpart text | The bundle has no Linux, OpenBSD or NetBSD trap page. The manual here says nothing about how trap behaves on those systems. Source: Bundle header (only a freebsd counterpart listed) |
Standards
- POSIX: trap is not listed as a POSIX.1-2024 utility in the bundle header.
- Solnix: The ksh93 section says signal numbers other than 1, 2, 3, 6, 9, 14 and 15 are not portable.
Writing portable scripts
- In scripts, trap only signals by name or by the numbers 1, 2, 3, 6, 9, 14 and 15, as the Solnix ksh93 text advises.
- Do not rely on ERR, DEBUG or KEYBD conditions, or on trap
-p, in portable scripts. The Solnix page documents them for ksh and ksh93, not for sh.
Every difference here is taken from the manual pages linked above: Solnix's published page, Linux (man-pages and the GNU and util-linux manuals), FreeBSD, OpenBSD and NetBSD. Each row names its source. Where a manual is silent, this page is too. Compiled 2026-10-26. Found a mistake? Mail hackers@lists.solnix.io.