[Top][All Lists]

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

[Help-bash] Signal delivery and select/read

From: Andreas Kusalananda Kähäri
Subject: [Help-bash] Signal delivery and select/read
Date: Sat, 20 Apr 2019 09:58:44 +0200
User-agent: Mutt/1.11.4 (2019-03-13)


I really just want to get some clarification and rationale behind how
"select" works vs. how "read" works when a signal is caught by a trap.

The observed behaviour (in a script, running under bash 5.0.3 on OpenBSD
6.4) is that if a trap is installed for e.g. SIGINT, then that signal
will be handled by the trap when the body of the "select" loop is about
to be executed, not while the "select" is waiting for user input.

This seems to follow the what's described in the manual:

    If bash is waiting for a command to complete and receives a signal
    for which a trap has been set, the trap will not be executed until
    the command completes.

However, "select" is a reserved word, not a command (the "select" loop
is a compound command though), and for something like "read", the trap
is executed immediately (and control is then handed back to the "read"

Could someone elaborate around the different behaviour and possibly give
further examples and pointers to the bits of the manual that I have

In POSIX mode, the trap handler is executed immediately and the command
("select" loop or "read") is cancelled.  The behaviour is consistent
between "select" and "read" in POSIX mode.


Andreas Kusalananda Kähäri,
National Bioinformatics Infrastructure Sweden (NBIS),
Uppsala University, Sweden.

reply via email to

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