How to find out if the program is running or not

There a a few ways to achieve this. Check out these threads:

I’d recommend using the RTDE interface, but you are not limited to solely this method.