Skip to content

Commit df8aebf

Browse files
kostorrteo
authored andcommitted
[cleanup-binary] Synchronize after kills
1 parent 98fc5bd commit df8aebf

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

cmd/o2-aliecs-shmcleaner

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,39 @@ export O2_ROLE=${O2_ROLE:-}
3030

3131
# ------ Beginning extra cleanup ------
3232
n=0
33-
for p in `pgrep -u flp`; do
33+
pids=$(pgrep -u flp)
34+
35+
# Try to kill any flp-owned processes gracefully
36+
for p in $pids; do
3437
c="`ps -ho %c $p`"
3538
[ "$c" = "o2-alf" ] && continue
3639
echo "Kill '%s' (PID:%s)\n" "`date`" "`hostname -s`" "$c" "$p" | $O2_INFOLOGGER_PATH/bin/o2-infologger-log -x -s Debug -o Facility=$O2_FACILITY -o Partition=$O2_PARTITION
3740
n=$((n+1))
3841
kill $p
3942
done
4043

44+
# Force kill any flp-owned processes remaining
4145
if (( n > 0 )); then
4246

4347
sleep 5
4448

45-
for p in `pgrep -u flp`; do
49+
for p in $pids; do
4650
c="`ps -ho %c $p`"
4751
[ "$c" = "o2-alf" ] && continue
48-
echo "Kill -9 '%s' (PID:%s)\n" "`date`" "`hostname -s`" "$c" "$p" | $O2_INFOLOGGER_PATH/bin/o2-infologger-log -x -s Debug -o Facility=$O2_FACILITY
52+
echo "Kill -9 '%s' (PID:%s)\n" "`date`" "`hostname -s`" "$c" "$p" | $O2_INFOLOGGER_PATH/bin/o2-infologger-log -x -s Debug -o Facility=$O2_FACILITY -o Partition=$O2_PARTITION
4953
kill -9 $p
5054
done
5155
fi
5256

57+
# Ensure that no flp-owned processes remain before returning
58+
if (( n > 0 )); then
59+
for p in $pids; do
60+
while [ kill -0 $p > /dev/null 2>&1]; do
61+
sleep 0.1
62+
done
63+
done
64+
fi
65+
5366
rm -f /dev/shm/*fmq*
5467

5568
yes | roc-cleanup --light > /dev/null 3>&1

0 commit comments

Comments
 (0)