Hi Ingo, On Thu, Jan 30, 2020, at 18:35, Ingo Schwarze wrote: > Hi Patrick, > > Patrick Kristiansen wrote on Tue, Jan 28, 2020 at 09:29:20AM +0100: > > > But another use for daemon(8) is for its ability to detach the child > > process from the controlling terminal and furthermore redirect its > > stdout/stderr to syslog. Is there some mechanism to do that from the > > shell? Perhaps a combination of nohup and starting a background job? > > That doesn't strike me as a particularly bright idea either. > > Properly starting up a daemon process requires several steps, often > involving unveil(2), pledge(2), chroot(2), prviledge dropping, > sometimes fork+exec for privilege separation, and so on. Typically, > these steps need to be intermixed in exactly the right order with > option parsing, environment parsing, parsing of configuration files > and various kinds of initialization.
The process I need to run is written in Clojure and thus runs on the Java Virtual Machine. Do you have any suggestions on how to best go about making it "daemon-like"? I am not sure that I can call unveil(2), pledge(2) and chroot(2) from Clojure without some strange sorcery. I read in some blog post, that the way to detach from the controlling terminal is by closing stdin, stdout and stderr, which I admittedly haven't tried. > Writing wrappers usually just doesn't work, and it seems doubtful to > me whether daemon(8) is up to what is usually needed. If I were writing my program in C, I could fairly easily call daemon(3), I guess, but I am not. I am starting to think that tmux(1) would be the easiest way to go about it on OpenBSD... but it feels wrong. Best regards, Patrick