1
0
Files
Laboratori-OS/Lab07/es5.sh
2024-03-22 16:54:05 +01:00

23 lines
372 B
Bash

#!/bin/bash
finds=0
while :
do
line=$(ps -el | tr -s " " | cut -d " " -f 2,4,14 | grep $1 | cut -d " " -f 1,2)
if [[ $(echo $line | cut -d " " -f 1) = "Z" ]]
then
let finds++
if [[ $finds -ge 5 ]]; then
pid=$(echo $line | cut -d " " -f 2)
kill -9 $pid
echo "Killed process $pid"
exit 0
fi
elif [[ $finds -ne 0 ]]
then
finds=0
fi
sleep $2
done