Page MenuHomeFreeBSD

sh: Do not ignore INTOFF during a trap
ClosedPublic

Authored by jilles on Jun 14 2020, 7:49 PM.

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
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; 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.