Re: EXIT trap does not fire

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

 



Hi,

On 12/11/2022 11:02, Akbarkhon Variskhanov wrote:
In bash, however, it seems to work fine. The action is executed and
the exit status is preserved.

This is not actually the case. bash will run EXIT actions on any signal that it installs a handler for, but it does not install a handler for all signals.

  $ bash -c 'trap "echo exit" EXIT; kill -PWR $$; echo still here'
  Power failure
$ bash -c 'trap "echo exit" EXIT; trap "exit" PWR; kill -PWR $$; echo still here'
  exit

I'm not sure what The Open Group is planning to do and whether or not
we're getting any clarification regarding this.

POSIX is making it unspecified what happens here:

  https://austingroupbugs.net/view.php?id=621

    The EXIT condition shall occur when the shell terminates normally
    (exits), and may occur when the shell terminates abnormally as a
    result of delivery of a signal (other than SIGKILL) whose trap
    action is the default.

The original proposed resolution listed a number of signals that would be required to be caught and to have EXIT handlers run. There were objections to that proposed resolution, it seemed unreasonable to require shells to install signal handlers for signals that scripts do not explicitly request signal handlers for.

Cheers,
Harald van Dijk



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

  Powered by Linux