ctdb-tests: Avoid early exits in scripts that appear on tail of a pipe
authorAmitay Isaacs <amitay@gmail.com>
Fri, 20 Mar 2015 03:36:51 +0000 (14:36 +1100)
committerMichael Adam <obnox@samba.org>
Fri, 20 Mar 2015 15:26:36 +0000 (16:26 +0100)
commit1f523a628ae05adfdda2c329af22788ba73ff759
treeee7b21f102af4d3cdc8f855acefde5d4198c8e5e
parent4f82ef4b388406e9a1c802adfc81b1786d6f786d
ctdb-tests: Avoid early exits in scripts that appear on tail of a pipe

When executing a shell script code "foo | bar", if "bar" terminates early,
then "foo" can get I/O error when writing to stdout.

The tdbtool stub did not wait to read anything from stdin when it is
expected to.  This would cause tests to fail randomly under load when
tdbtool process exited early.

Similarly, debug function read from stdin only under certain conditions
(higher debug and when not reading from tty).  Otherwise, exited early.

Thanks to Andrew Bartlett for noticing the problem and Catalyst Cloud
(http://catalyst.net.nz/cloud) for providing resources to test fixes.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Pair-Programmed-With: Martin Schwenke <martin@meltin.net>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Fri Mar 20 16:26:37 CET 2015 on sn-devel-104
ctdb/config/functions
ctdb/tests/eventscripts/stubs/tdbtool