This looks correct to me:

me@myhost>$ bash
me@myhost>$ export PS1='Prompt> '; trap 'echo I' int; (while kill -int $$;
do sleep 1; done) &
[1] 65437
Irompt> ^C //// "^C" printed by kernel/bash on receipt of SIGINT

Irompt> ^C

Irompt> ^C

Prompt> ////here I press ^D and exit bash started in 1st line of the example
exit
me@myhost>$ bash: line 1: kill: (65408) - No such process


Now the same but with SIGTERM:

me@myhost>$ bash
me@myhost>$ export PS1='Prompt> '; trap 'echo T' term; (while kill $$; do
sleep 1; done) &
[1] 65964
Prompt>
exit
me@myhost>$ bash: line 1: kill: (65904) - No such process

without me pressing anything. Why did bash exit?! The trap does not contain
any 'exit' commands!

bash --version
GNU bash, version 5.3.9(1)-release (x86_64-redhat-linux-gnu)
  • trapped SIGT... Denys Vlasenko via Bug reports for the GNU Bourne Again SHell
    • Re: tra... Chet Ramey
      • Re:... Denys Vlasenko via Bug reports for the GNU Bourne Again SHell
        • ... Chet Ramey
          • ... Denys Vlasenko via Bug reports for the GNU Bourne Again SHell
    • Re: tra... Stan Marsh
      • Re:... Greg Wooledge
        • ... Chet Ramey
        • ... FĂ©lix Hauri via Bug reports for the GNU Bourne Again SHell

Reply via email to