codywd/NetGUI — pull request #6 by coquelicot (2014-02-08 04:43:25+00:00)
Title: Fix bug of the pidFile mechanism.

1. Cleanup should be called at the end instead of start.
Since it'll remove the pidFile we just created.

2. Unlock must come after unlink or we'll suffer race condition.
EX: procA launched -> procA process -> procA unlock ->
procB launched -> procA unlink
Oops, procA remove procB's pidFile...

3. We must open pidFile with os.open + os.fdopen or the pidFile
will be truncated even if our netgui is still running.
It won't cause any problem now, however, it's a potential bug.