7928 Add support for SMF_EXIT_NODAEMON

Review Request #1495 - Created Feb. 20, 2019 and submitted

Information
Andy Fiddaman
illumos-gate
master
7928
3839cd5...
Reviewers
general
7928 Add support for SMF_EXIT_NODAEMON

Upstream of part of Joyent's OS-1159
Work by Jerry Jelinek


Some services do not need to run inside a zone and so currently spawn a background while/sleep loop so that the service contract does not become empty.

For example, the datalink-management service method contains:

if smf_is_nonglobalzone; then
    (while true ; do sleep 3600 ; done) & 
    exit $SMF_EXIT_OK
fi

and in an NGZ:

root@hawkeye:~# ps -ef | grep dlm
    root  4513  4302   0   Jan 22 ?           0:00 /sbin/sh /lib/svc/method/svc-dlmgmtd

root@hawkeye:~# pstack 4513
4513:   /sbin/sh /lib/svc/method/svc-dlmgmtd
 feeec3e7 pause    ()
 fed67c98 sleep    (e10, 0, ffffffff, fed67d5d, 0, 40ac2000) + 8a
 fed67da5 sh_delay (0, 40ac2000, 15, fed68195) + 55
 fed681b3 b_sleep  (2, 80afd98, fedef164, 0, 90a7369, 0) + 39d
 fedb9d6b sh_exec  (80afd50, 4, 80472cc, fedb8d86, 80472f4, fec00e00) + ff6
 fedbbba7 sh_exec  (80afcd4, 85, 8047678, fedbab50) + 2e32
 fedbab67 sh_exec  (80afdb4, 4, 80afc6c, fedb8d86, 80b2058, 0) + 1df2
 fedbb36e sh_exec  (80afe18, 4, 2, fedb8d86, 0, 0) + 25f9
 fedbbeeb sh_exec  (80afc3c, 24, 0, fed9835e) + 3176
 fed9859e exfile   (fedeee80, 80bac40) + 7c9
 fed9900c sh_main  (2, 8047de0, 0, 0) + 889
 08051040 main     (fedf0140, fef67388, 8047db8, 8050f08, 2, 8047de0) + 56
 08050f08 _start_crt (2, 8047de0, fefd0d40, 0, 0, 0) + 97
 08050dda _start   (2, 8047ec8, 8047ed1, 0, 8062260, 8047f11) + 1a

With this change, the service method can exit SMF_EXIT_NODAEMON which satisfies all dependencies and does not leave a process hanging around.

Most whitespace nit fixes are in the second patch set.

Andy Fiddaman
Igor Kozhukhov
Jason King
Andrew Stormont
Andy Fiddaman
Gergő Mihály Doma
Andy Fiddaman
Review request changed

Status: Closed (submitted)

Loading...