I'm developing a long running command line script and of course I want in not to launch itself more than once. So I write a .pid file and on launch check if a process with such PID exists. The problem is on Windows it returns 0 as a PID, so I always get a process by that PID running (System Idle has PID 0).
Does someone know how to fix that? Can I make a daemon running on windows? Maybe the fix will be forking with pcntl_fork?
P.S. I'm using Yii and it's CConsoleCommand class as a base.