[HN Gopher] Beginner's Guide to Understanding Daemons ___________________________________________________________________ Beginner's Guide to Understanding Daemons Author : aryamansharda Score : 62 points Date : 2020-09-03 05:27 UTC (17 hours ago) (HTM) web link (blog.digitalbunker.dev) (TXT) w3m dump (blog.digitalbunker.dev) | zokier wrote: | With systemd (and afaik other service managers) you don't | need/should to do all that daemonization dance. The application | can run in the foreground, keep any fds open, don't worry about | tty etc because the service manager will take care of them for | you. As a cherry on top, anything you write on stdout gets | automatically forwarded to journald or wherever. | | further reading https://www.man7.org/linux/man- | pages/man7/daemon.7.html | gilgad13 wrote: | My understanding was that the double fork dance was actively | _discouraged_ for any semi-modern system. The man page you link | says as much in the "new-style" section, as well as | https://jdebp.eu/FGA/unix-daemon-design-mistakes-to- | avoid.ht.... | | Just write your server as a straightforward process and let the | service manager handle this stuff for you. You'll just be | confusing it if you don't. | JdeBP wrote: | It is rather sad to see something that was out of date in the | 1990s still being circulated _today_. Even the part about | process #1 inheriting orphaned processes is 8 or so years out | of date. | | * https://unix.stackexchange.com/a/177361/5132 | pmiller2 wrote: | > Simply put, a daemon (pronounced dee-mon) is an intentionally | orphaned background process. Additionally, daemons are detached | from the terminal in which they're spawned, operate without user | interaction, and are descendants of the system's init process. | | A memorable way to think about this is that a daemon is a child | process whose parent has literally disowned it, forked off, and | died. | JdeBP wrote: | ... except that that's most definitely _not_ the defining | characteristic, and the defining characteristic is rather that | the process isn 't part of a login session, which ironically on | modern operating systems with all of the one-way trapdoors that | now exist one cannot reach by forking. | | * https://unix.stackexchange.com/a/606902/5132 | | Thinking that forking makes a daemon is much the same error as | thinking that su drops privileges, it conflates what happend to | be a _mechanism_ from years ago with the actual purpose, | totally missing that things have changed since (long since, | decades ago in fact). | macintux wrote: | Of all the great content in APUE, I think W. Richard Stevens' | (RIP) coverage of daemonization is the only piece I've ever used. | | Fortunately I recently replaced my lost 1st edition with a 2nd | edition, and the coverage looks similar. From what I can see | there are two details left out of this article: | | * _Why_ changing the working directory is important (so the | daemon doesn't accidentally prevent a file system from being | unmounted in the future). | | * WRS emphasized logging. | | Some of the details are different (umask as the first function | instead of the last), but the highlights are comparable. | timw4mail wrote: | Going by the spelling, isn't it pronouced day-mon? | SmooL wrote: | I've also been pronouncing it like this and so far I've never | been called out, maybe I just have nice friends? | macintux wrote: | I have to admit to pronouncing it consistently | "daymonization" and sometimes but not always "demon". | cptnapalm wrote: | The -ae diphthong is usually pronounced like -ee. For some | variety, you can use the Latin pronunciation which would be | pronounced like -ai or 'eye'. | codewritinfool wrote: | like demon. | jpxw wrote: | No, in the same way that paediatrician isn't pronounced | paydiatrician | pmiller2 wrote: | It's also not spelled "paediatrician" in American English, | hence the confusion. | aryamansharda wrote: | I was a bit conflicted on the pronunciation, but after | verifying with a few sources it seems like it's pronounced just | like "demon" | | https://en.wikipedia.org/wiki/Daemon_(computing)#:~:text=The... | . ___________________________________________________________________ (page generated 2020-09-03 23:00 UTC)