Page MenuHomeFreeBSD

sh: Do not ignore INTOFF during a trap
ClosedPublic

Authored by jilles on Jun 14 2020, 7:49 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Dec 31, 3:30 PM
Unknown Object (File)
Tue, Dec 30, 3:39 AM
Unknown Object (File)
Dec 2 2025, 5:19 AM
Unknown Object (File)
Nov 30 2025, 6:28 PM
Unknown Object (File)
Nov 28 2025, 10:09 PM
Unknown Object (File)
Nov 25 2025, 7:49 AM
Unknown Object (File)
Nov 25 2025, 7:49 AM
Unknown Object (File)
Nov 25 2025, 7:49 AM
Subscribers

Details

Summary

INTOFF postpones SIGINT processing and INTON enables it again. This is
important so an interactive shell can return to the top level prompt when
Ctrl+C is pressed.

Given that INTON is automatically done when a builtin completes, the part
where onsig() ignores suppressint when in_dotrap is true is both unnecessary
and unsafe. If the trap is for some other signal than SIGINT, arbitrary code
could have been interrupted.

Historically, INTOFF remained in effect for longer.

Test Plan

installworld; kyua test in /usr/tests/bin/sh

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Tested this with a builtin and agree it's redundant and dangerous.

This revision is now accepted and ready to land.Jul 9 2020, 8:26 PM
This revision was automatically updated to reflect the committed changes.