bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

trapped SIGTERM unexpectedly makes bash exit when received


From: Denys Vlasenko
Subject: trapped SIGTERM unexpectedly makes bash exit when received
Date: Sun, 11 Oct 2026 16:33:25 +0200

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)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]