Mmmm I didn't dig very deeply into daemontools, but it didn't seem somethig that mixed the daemon with the controlling script, although I may be mistaken (I just took a glance at it).
Rather, it seems to be a framework to provide systemd-like capabilities to the system.

Correct. Let me show how daemontools work on my little server at home:

Output of pstree:

init-+-crond : : |-sshd---sshd---sshd---bash---bash---pstree |-svscanboot-+-readproctitle | `-svscan-+-supervise---ntpd | |-supervise---xfs | |-4*[supervise] | |-8*[supervise---multilog] | |-supervise---fetchmail | |-supervise---exim | |-supervise---server | |-supervise---vnc-fwd | |-supervise---cupsd | |-supervise---mdadm | |-supervise---postmaster---4*[postmaster] | |-supervise---powersocket | `-supervise---vboxwebsrv---8*[{vboxwebsrv}] |-syslogd |-udevd---udevd : : `-ypserv

tree -l in /service

├── cups -> /var/svc.d/cups
│   ├── run
│   └── supervise
│       ├── control
│       ├── lock
│       ├── ok
│       └── status
├── exim -> /var/svc.d/exim
│   ├── run
│   └── supervise
│       ├── control
│       ├── lock
│       ├── ok
│       └── status
├── fetchmail -> /var/svc.d/fetchmail
│   ├── conffile
│   ├── fetchmail.conf
│   ├── fetchmail.conf-working
│   ├── log
│   │   ├── run
│   │   ├── run~
│   │   └── supervise
│   │       ├── control
│   │       ├── lock
│   │       ├── ok
│   │       └── status
│   ├── pid
│   │   └── fetchmail.pid
│   ├── run
│   ├── status
│   ├── supervise
│   │   ├── control
│   │   ├── lock
│   │   ├── ok
│   │   └── status
│   └── wake
├── mdadm-monitor -> /var/svc.d/mdadm-monitor/
│   ├── run
│   ├── run~
│   └── supervise
│       ├── control
│       ├── lock
│       ├── ok
│       └── status
├── ntpd -> /var/svc.d/ntpd
│   ├── run
│   └── supervise
│       ├── control
│       ├── lock
│       ├── ok
│       └── status
├── pg9 -> /var/svc.d/pg9
│   ├── log
│   │   ├── run
│   │   └── supervise
│   │       ├── control
│   │       ├── lock
│   │       ├── ok
│   │       └── status
│   ├── run
│   └── supervise
│       ├── control
│       ├── lock
│       ├── ok
│       └── status
├── printerpower -> /var/svc.d/printerpower
│   ├── down
│   ├── log
│   │   ├── run
│   │   └── supervise
│   │       ├── control
│   │       ├── lock
│   │       ├── ok
│   │       └── status
│   ├── run
│   └── supervise
│       ├── control
│       ├── lock
│       ├── ok
│       └── status
├── save-attachments -> /var/svc.d/save-attachments
│   ├── log
│   │   ├── run
│   │   ├── run~
│   │   └── supervise
│   │       ├── control
│   │       ├── lock
│   │       ├── ok
│   │       └── status
│   ├── run
│   └── supervise
│       ├── control
│       ├── lock
│       ├── ok
│       └── status
├── smartd -> /var/svc.d/smartd
│   ├── down
│   ├── run
│   ├── run~
│   └── supervise
│       ├── control
│       ├── lock
│       ├── ok
│       └── status
├── vboxweb -> /var/svc.d/vboxweb
│   ├── log
│   │   ├── run
│   │   └── supervise
│   │       ├── control
│   │       ├── lock
│   │       ├── ok
│   │       └── status
│   ├── run
│   ├── run~
│   └── supervise
│       ├── control
│       ├── lock
│       ├── ok
│       └── status
├── vnc-fwd -> /var/svc.d/vnc-fwd
│   ├── bin
│   │   └── vnc-fwd
│   ├── lib
│   │   └── Foken
│   │       ├── VNCForward
│   │       │   ├── HTTPd
│   │       │   │   ├── RH
│   │       │   │   │   ├── debug.pm
│   │       │   │   │   └── vnc.pm
│   │       │   │   ├── RH.pm
│   │       │   │   ├── Request.pm
│   │       │   │   └── RequestHandler.pm
│   │       │   ├── HTTPd.pm
│   │       │   ├── Object.pm
│   │       │   ├── VNCd
│   │       │   │   └── Request.pm
│   │       │   └── VNCd.pm
│   │       └── VNCForward.pm
│   ├── run
│   ├── static
│   │   ├── debug.html
│   │   ├── index.html
│   │   ├── style.css
│   │   ├── vnc_logo.png
│   │   └── vnc_logo_background.png
│   ├── supervise
│   │   ├── control
│   │   ├── lock
│   │   ├── ok
│   │   └── status
│   └── template
│       ├── layout
│       └── vnc
│           ├── default
│           ├── edit
│           └── ip
└── xfs -> /var/svc.d/xfs
    ├── run
    ├── run~
    └── supervise
        ├── control
        ├── lock
        ├── ok
        └── status

You can ignore the supervise directories, they are generated and controled by the supervise program, and you should not mess with them. Essentially, you have one directory for each service. Inside that directory, you have a run program (typically a shell script), and optionally a log directory for a logging service, again with a run program. Typically, log/run starts multilog. Optionally, a service directory may also contain a down entry that prevents an automatic start of the service. You can see that in smartd and printerpower. Other files and directories are allowed, you can see that in fetchmail and even more in vnc-fwd (a daemon written in Perl).

You don't see any run programs in the process list. This is because run typically replaces itself with the actual daemon program. This typically happens indirectly, via a chain of helper programs, each modifies the environment a little bit, then replaces itself with the next program. The most common one is setuidgid, that sets the real and effective user and group IDs to the user given as first argument, then replaces itself with the program in its second argument, passing all remaining parameters to the program.

Output of find -L . -type f -name run -printf '*** %p ***\n' -exec cat {} \;

*** ./ntpd/run *** #!/bin/sh exec 2>&1 echo "*** Starting ntpd ***" exec \ /usr/sbin/ntpd -g -n *** ./xfs/run *** #!/bin/sh exec 2>&1 echo "Starting X font server ..." exec \ /usr/bin/xfs \ -nodaemon \ -droppriv \ -user nobody *** ./fetchmail/log/run *** #!/bin/sh exec \ setuidgid nobody \ multilog t s1000000 /var/multilog/fetchmail *** ./fetchmail/run *** #!/bin/sh exec 2>&1 echo "*** Starting fetchmail service ...***" if [ "$(pidof exim)" = "" ] ; then echo "exim not running, exiting" exit 1 fi exec \ env FETCHMAILHOME="./pid" \ setuidgid fetchmail \ fetchmail -v -f ./fetchmail.conf --nodetach *** ./exim/run *** #!/bin/sh exec 2>&1 echo "*** Starting exim ***" exec \ /opt/exim/bin/exim -bdf -q25m *** ./vboxweb/log/run *** #!/bin/sh exec \ setuidgid nobody \ multilog t s1000000 /var/multilog/vboxweb *** ./vboxweb/run *** #!/bin/sh exec 2>&1 echo "*** Starting vboxweb service ...***" exec \ /opt/VirtualBox/vboxwebsrv # -v *** ./save-attachments/log/run *** #!/bin/sh exec \ setuidgid nobody \ multilog t s1000000 /var/multilog/save-attachments *** ./save-attachments/run *** #!/bin/sh exec 2>&1 echo "*** Starting save-attachments ***" exec \ setuidgid gs \ /home/gs/save-attachments/server *** ./printerpower/log/run *** #!/bin/sh exec \ setuidgid nobody \ multilog t s1000000 /var/multilog/printerpower *** ./printerpower/run *** #!/bin/sh exec /usr/lib64/cups/backend/powersocket --daemon *** ./vnc-fwd/run *** #!/bin/sh exec \ setuidgid nobody \ bin/vnc-fwd *** ./cups/run *** #!/bin/sh exec 2>&1 echo "*** Starting cups ***" # Set the timezone, if possible. This allows the scheduler and all ch +ild # processes to know the local timezone when reporting dates and times +to the # user. If no timezone information is found, then Greenwich Mean Time + (GMT) # will probably be used. [ "$TZ" ] && export TZ # Don't use TMPDIR environment variable from init script, as that can +cause # cupsd to set TempDir to a user's temporary directory instead of the # default. unset TMPDIR exec \ /usr/sbin/cupsd -f *** ./mdadm-monitor/run *** #!/bin/sh exec 2>&1 echo "*** Starting mdadm-monitor ***" exec \ mdadm --monitor \ --syslog \ --mail=root@localhost \ --delay=300 \ --test \ /dev/md0 /dev/md1 /dev/md2 *** ./smartd/run *** #!/bin/sh echo '*** starting smartd ***' exec 2>&1 # exec \ /usr/sbin/smartd -n echo "*** smartd crashed !!! ***" exec /command/svc -d . *** ./pg9/log/run *** #!/bin/sh exec \ setuidgid nobody \ multilog t s1000000 /var/multilog/pg9 *** ./pg9/run *** #!/bin/sh PGDATA=/data/pgdata exec 2>&1 echo "Starting postgresql with PGDATA=$PGDATA" exec \ setuidgid postgres \ /opt/pg9/bin/postmaster -D "$PGDATA"

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

In reply to Re^5: RFC: an(other) UNIX daemon module implementation by afoken
in thread RFC: an(other) UNIX daemon module implementation by mantager

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.