I'm going to assume (bad idea, I know) that you're wanting to run this on linux. As such, linux stores process information in /proc/<pid>/. You could simply stat() the directory. If it exists, the process is running. If it fails, the process has ended.