Removing the sleep 0.5 we hit a race where the "-f /proc/$pid_app"
test returns false immediately. Using "kill -0" protects us against
such races. From kill (2):
If sig is 0, then no signal is sent, but existence and permission
checks are still performed; this can be used to check for the
existence of a process ID or process group ID that the caller is
permitted to signal.
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
touch "$file_sync_wait_before_unshare"
- # Let the app do it's thing before entering the synchronisation loop
- sleep 0.5
-
while [ ! -f "$file_sync_signal_after_unshare" ]; do
# Break if the app failed / died
- if [ ! -f "/proc/$app_pid" ]; then
+ if ! kill -0 "$app_pid" ; then
break
+ echo "# App failed"
fi
echo "# Waiting for app..."
sleep 0.5
$TESTAPP_BIN -n "$ns" -i $NUM_EVENT -a "$file_sync_after_unshare" -b "$file_sync_before_last" &
app_pid=$!
- # Let the app do it's thing before entering the synchronisation loop
- sleep 0.5
-
while [ ! -f "$file_sync_after_unshare" ]; do
# Break if the app failed / died
- if [ ! -f "/proc/$app_pid" ]; then
+ if ! kill -0 "$app_pid" ; then
+ echo "# App failed"
break
fi
echo "# Waiting for app..."