On 1/28/20 9:29 AM, Patrick Kristiansen wrote: > Hi Ingo > > Thank you for your reply. > > I can't say I disagree with your and the OpenBSD team's attitude about > bug-free daemons. But I am just a lowly application programmer, and > sometimes I introduce horrible bugs that make our systems crash. In many > cases it will be preferable to just start the process again (and, of > course, fix the bug) for the purposes of keeping our business running.
Everyone has a testing environment, not everyone has a production environment... > > 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? I once had to write a support script in shell that needed to run as daemon, basically some action needed to be taken if something was found in a log-file. To do this I did exactly what you said: nohup <command> 2>&1 | logger <params> & and put this inside an rc.d file or equivalent format of your OS of choice. now I'm not promoting this kind of hackery, but this worked for me quite reliably at the time. martijn@ > > Best regards, > Patrick > >> Hi Patrick, >> >> Patrick Kristiansen wrote on Mon, Jan 27, 2020 at 08:13:28PM +0100: >> >>> Is there something like the FreeBSD daemon(8) command for OpenBSD, >>> which can run a process in the background and restart it if it >>> crashes? >> >> Absolutely not, we are strongly convinced this is an utterly stupid >> idea and a serious security risk. >> >> If a daemon crashes, it has a bug. Many bugs that cause crashes >> are also exploitable. So if a daemon crashes, you first have to >> understand why it crashed, fix or at least mitigate the bug, and >> can only restart it afterwards. >> >> Restarting it automatically is an irresponsible thing to do. >> >> If a daemon keeps crashing so frequently that you can only run it >> in production with automatic restarts, then running it at all is >> irresponsible in the first place. >> >> Yours, >> Ingo >