I have written a loop to iterate all .out c binary file and copy their outputs into a text file (the output for every binary file is just a one line hash value, one line output for one program). Here is my code so far:for j in {1..10}do    ./gcc-$j.out >> gcc-result.txtdoneUnfortunately, some binary files have some unknown issues and cannot be correctly executed (they got stuck and cannot proceed to the next program).I am not going to fix those c code but I want my bash to automatically jump to executing the next program within a given timeout (say 10 secs), and also write 0 to the gcc-result.txt.Thanks in advance if you have idea to solve this issue.
Jump out of a process when it get stuck
bash;scripting
You could use the timeout command :if timeout 10 ping google.fr > /dev/nullthen    echo process successfulelse    echo process killedfishows process killed, andif timeout 10 ls /usr/bin | wc -l > /dev/nullthen    echo process successfulelse    echo process killedfishows process successful. Based on this, you could run each command using such an if; then; else; fi, redirect the standard output to a temporary file, and copy that temporary to the target file in the successful case, while generating the target file in the failure case.How can I kill a process and be sure the PID hasn't been reused could be helpful in case you don't have timeout.