Genaral advice: Use an Event-loop system, which runs on Windows, like AnyEvent or Glib . Your event loop will spawn the program, in a way to get it's PID. Your eventloop runs a timer, to see when that troublesome program has finished, and then sends a Kill signal to it. See Roll your own Event-loop for a simple example.