[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-bash] run-parts, trap INT, read error
From: |
Patrick Schleizer |
Subject: |
[Help-bash] run-parts, trap INT, read error |
Date: |
Tue, 24 Mar 2015 16:26:17 +0000 |
Hi!
I got a strange issue run-parts in conjunction with signal sigint
handling. Difficult to describe. Therefore I post example test scripts
on how to reproduce this.
During the 'sleep', I will hit 'ctrl + c'. (You'll see this in the
output '^C'.)
----------
./parent:
#!/bin/bash
set -x
error_handler_parent() {
true "$FUNCNAME: Exiting"
exit 1
}
trap "error_handler_parent" ERR
main() {
trap "error_handler_parent" ERR
## Issue.
run-parts --verbose --exit-on-error ./test.d
## Functional.
#./test.d/child
true
}
main
----------
./test.d/child:
#!/bin/bash
set -x
int_test() {
true "Enter!"
read -p "Question..." answer
true "answer: $answer"
}
trap "int_test" INT
sleep 60 &
wait $!
true "END"
----------
Output:
$ ./parent
+ trap error_handler_parent ERR
+ main
+ trap error_handler_parent ERR
+ run-parts --verbose --exit-on-error ./test.d
run-parts: executing ./test.d/child
+ trap int_test INT
+ wait 21061
+ sleep 60
^C++ int_test
++ true 'Enter!'
++ read -p Question... answer
Question...
[back in shell]
[press enter]
$ ./test.d/child: line 7: read: read error: 0: Input/output error
++ true 'answer: '
+ true END
-----
Where is the read error coming from?
Why is the script continuing to run in background?
If I use './test.d/child' instead of run-parts, this issue does not happen.
Cheers,
Patrick
- [Help-bash] run-parts, trap INT, read error,
Patrick Schleizer <=