3
With the following code we check if a process is running:
#!/bin/bash
#Verificar se processo abc está em execução
if pgrep "abc" >/dev/null 2>&1
then
printf "Está em execução.\n" >&2
else
printf "Não está em execução.\n" >&2
fi
exit
But if the process name has more than 15 characters, for example abcdefghijklmnop, I’ll always get Não está em execução. because the pgrep failure due to the 15 character limit from the size limit in the field with of the files in /proc/[pid]/stat.
Question
How can I refactor the code above in order to exceed the 15 character limit ?