Detect running state based on the exit status