sharness: only send kill signal once - #1106
sharness should only send the kill signal once, as that is what a graceful shutdown should do. in the event that doesn't happen, we should send it again, and then kill -9 to prevent it lingering and messing with other tests.
Juan Batiz-Benet committed
Apr 21, 2015 at 00:24 UTC
cf797d3d02dd7ddc7c44892551d9e7f2f190e40b
1 file changed
+11
-2
test/sharness/lib/test-lib.sh
+11
-2
@@ -236,13 +236,22 @@ test_launch_ipfs_daemon_and_mount() {
236
}
237
238
test_kill_repeat_10_sec() {
239
+ # try to shut down once + wait for graceful exit
240
+ kill $1
241
for i in 1 2 3 4 5 6 7 8 9 10
242
do
241
- kill $1
243
sleep 1
244
! kill -0 $1 2>/dev/null && return
245
done
245
- ! kill -0 $1 2>/dev/null
246
+
247
+ # if not, try once more, which will skip graceful exit
248
+ kill $1
249
+ sleep 1
250
+ ! kill -0 $1 2>/dev/null && return
251
+
252
+ # ok, no hope. kill it to prevent it messing with other tests
253
+ kill -9 $1 2>/dev/null
254
+ return 1
255
}
256
257
test_kill_ipfs_daemon() {