Changed Daemonize() to use an new daemonize() implementation that doesn't rely on cgo at all. This ought to make it easier to build for more operating systems, such as FreeBSD (see #156).
The new daemonize() completes steps 5-9 and 11 (and 14-15 to some extent) from this list. These steps all come "for free" with various options to os.StartProcess(). The missing steps would either need the syscall package or weren't clearly needed.
Compared to VividCortex/godaemon, the only real difference is that there's no syscall.Umask(0), which is step 10 from the list above. It's also used differently:
if !isDaemonized() {
// put any one-time init here, not repeated in children
err = daemonize([]*os.File{newStdin, newStdout, newStderr, ...})
if err != nil {
os.Exit(1)
}
}
// continue here
Probably best to compare old vs. new side-by-side, since the diff is hard to follow.
Wouldn't necessarily be opposed to adding more (e.g. syscall.Umask(0)), but this seems like a good starting point.
Changed
Daemonize()
to use an newdaemonize()
implementation that doesn't rely on cgo at all. This ought to make it easier to build for more operating systems, such as FreeBSD (see #156).The new
daemonize()
completes steps 5-9 and 11 (and 14-15 to some extent) from this list. These steps all come "for free" with various options toos.StartProcess()
. The missing steps would either need the syscall package or weren't clearly needed.Compared to VividCortex/godaemon, the only real difference is that there's no syscall.Umask(0), which is step 10 from the list above. It's also used differently:
Probably best to compare old vs. new side-by-side, since the diff is hard to follow.
Wouldn't necessarily be opposed to adding more (e.g.
syscall.Umask(0)
), but this seems like a good starting point.