Last active
May 16, 2024 14:00
-
-
Save coproduto/573064da64b7aaf9f8e166ad8e0e1ffc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
trap : SIGTERM SIGINT # : é um noop - só estamos dizendo que queremos receber os sinais | |
echo $$ # $$ contém o PID do próprio script | |
find / >/dev/null 2>&1 & | |
FIND_PID=$! # $! contém o PID do último processo iniciado | |
wait $FIND_PID # Esperamos até o PID encerrar ou recebermos um sinal | |
# $? contém o status de retorno do último processo encerrado | |
# Se o `wait` terminou porque o processo iniciado encerrou, status <= 128 | |
# Já se o `wait` terminou por receber um sinal, status > 128 | |
if [[ $? -gt 128 ]] | |
then | |
kill $FIND_PID | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment