Replace wait_for_file
with more reliable checks
Similar to what has been done in !85 (merged) , we should review uses of wait_for_file
in the PID logic or other parts of the code. Instead of just waiting for a file to exist, we should implement more robust conditions if possible, such as validating that a process is running, and improved logging to ensure reliability.