Re: EXIT trap does not fire

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

 



Paul Smith wrote in
 <c9c96d88c226cc9db0d447fc1160608a6c5e0362.camel@xxxxxxxxxxxxxxxxx>:
 |On Tue, 2022-05-31 at 16:39 -0400, charles.fisher@xxxxxxxxxxx wrote:
 |> The ssh-agent used in the context immediately below seems to prevent
 |> an EXIT trap from firing upon abnormal termination:
 |
 |Unfortunately it's not clearly specified in the standard what should
 |happen in this situation.  There is an open issue about this:
 |
 |https://austingroupbugs.net/view.php?id=621
 |
 |and here it's pointed out that many shells do not run the EXIT trap
 |when a signal is received, but a few do (bash is one of the few).  So,
 |this is just an unfortunately unclear area of the standard and shells
 |choose to do different things depending on what they interpret "exit"
 |to mean: if they interpret it to mean only "normal exit, by someone
 |running exit or reaching EOF" then they will behave as dash does.  If
 |they interpret it to mean "the shell process is going away for any
 |reason", then they'll interpret it as bash does.
 |
 |You can, of course, add multiple conditions:
 |
 |   trap ... EXIT INT ABRT KILL TERM

I do

  trap "echo on exit" EXIT
  trap "trap '' INT HUP QUIT TERM; exit 1" INT HUP QUIT TERM

So whether it truly protects everywhere i do not know.

 |or similar so both possibilities are catered to.
 --End of <c9c96d88c226cc9db0d447fc1160608a6c5e0362.camel@xxxxxxxxxxxxxxxxx>

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux