rstudio/httpuv — pull request #20 by hcorrada (2013-10-30 16:14:11+00:00)
Title: Daemoning server on unix platforms

Here is a draft implementation of daemonizing for Unix systems. Here is a rough idea of how it works:

/*
* Daemonizing on unix
*
* Uses the R event loop to trigger the libuv default loop. This is a similar mechanism as that used by Rhttpd.
* It adds an event listener on the port where the TCP server was created by libuv. This triggers uv_run on the
* default loop any time there is an event on the server port. It also adds an event listener to a file descriptor
* exposed by the uv_default_loop to trigger uv_run whenever necessary. It uses the non-blocking version
* of uv_run (UV_RUN_NOWAIT).
*
*/