indexzero/daemon.node — pull request #15 by AvianFlu (2012-02-26 00:58:05+00:00)
Title: Fix: Pass filename down from JS, then open file in C++.

The existing implementation opens a file descriptor asynchronously in javascript, then passes the integer returned down to C++, and expects the file table to still be in the same state after a `fork(2)`. Sometimes, this just fails and log files are mysteriously empty - in general, this seems to leak a fair bit of memory.

This patch changes things around so that a filename is instead taken as an argument in javascript, and the file descriptor is not opened until after the `fork(2)` call.

This simplification so far seems to prevent the stdio-related issues, and has, according to local testing, eliminated at least most of the memory leak.

I've also removed the `SetSid()` method. Put briefly, it shouldn't be exposed to javascript by itself.

This should be released with a minor version bump, as it breaks the call signature of `daemon.start`, which now takes string filenames instead of file descriptors.