blob: 7e6885560847429b30fbccc889a299cf387b738d [file] [log] [blame]
Denis Vlasenkoa19e6492009-03-11 14:40:00 +00001 Logging and backgrounding
2
3By default, bb_[p]error_msg[_and_die] messages go to stderr,
4and of course, usually applets do not auto-background. :)
5
6Historically, daemons and inetd services are different.
7
8Busybox is trying to provide compatible behavior, thus if an applet
9is emulating an existing utility, it should mimic it. If utility
10auto-backgrounds itself, busybox applet should do the same.
11If utility normally logs to syslog, busybox applet should do
12the same too.
13
14However, busybox should not needlessly restrict the freedom
15of the users. And users have different needs and different preferences.
16Some might like logging everything from daemons to syslog.
17Others prefer running stuff under runsv/svlogd and thus would like
18logging to stderr and no daemonization.
19
20To help with that, busybox applets should have options to override
21default behavior, whatever that is for a given applet.
22
23
Denys Vlasenko5370bfb2009-09-06 02:58:59 +020024Current situation is a bit of a mess:
Denis Vlasenkoa19e6492009-03-11 14:40:00 +000025
26acpid - auto-backgrounds unless -d
27crond - auto-backgrounds unless -f, logs to syslog unless -d or -L.
28 option -d logs to stderr, -L FILE logs to FILE
29devfsd - (obsolete)
Denis Vlasenko4221e902009-03-11 15:07:44 +000030dnsd - option -d makes it background and log to syslog
Denis Vlasenkoa19e6492009-03-11 14:40:00 +000031fakeidentd - inetd service. Auto-backgrounds and logs to syslog
32 if no -f and no -i and no -w (-i is "inetd service" flag,
33 -w is "inetd-wait service" flag)
Denis Vlasenko4221e902009-03-11 15:07:44 +000034ftpd - inetd service. Logs to syslog with -S, with -v logs to strerr too
35httpd - auto-backgrounds unless -f or -i (-i is "inetd service" flag)
Denis Vlasenkoa19e6492009-03-11 14:40:00 +000036inetd - auto-backgrounds unless -f, logs to syslog unless -e
37klogd - auto-backgrounds unless -n
38syslogd - auto-backgrounds unless -n
Denis Vlasenko4221e902009-03-11 15:07:44 +000039telnetd - auto-backgrounds unless -f or -i (-i is "inetd service" flag)
Denis Vlasenkoa19e6492009-03-11 14:40:00 +000040udhcpc - auto-backgrounds unless -f after lease is obtained,
41 option -b makes it background sooner (when lease attempt
42 fails and retries start),
43 after backgrounding it stops logging to stderr;
44 logs to stderr, but option -S makes it log *also* to syslog
45udhcpd - auto-backgrounds and do not log to stderr unless -f,
46 otherwise logs to stderr, but option -S makes it log *also* to syslog
47zcip - auto-backgrounds and logs *also* to syslog unless -f
48
Denis Vlasenko4221e902009-03-11 15:07:44 +000049Total: 13 applets (+1 obsolete),
50 4 log to syslog by default (crond fakeidentd inetd zcip),
51 5 never log to syslog (acpid httpd telnetd klogd syslogd, last two
52 - for obviously correct reasons),
53 there are no daemons which always log to syslog,
Denys Vlasenko5370bfb2009-09-06 02:58:59 +020054 12 auto-background if not run as inetd services (all except dnsd.
Denis Vlasenko4221e902009-03-11 15:07:44 +000055 Note that there is no "standard" dnsd AFAIKS). But see below
56 for daemons (tcpsvd etc) which don't auto-background.
57
Denis Vlasenkoa19e6492009-03-11 14:40:00 +000058miscutils/crond.c: logmode = LOGMODE_SYSLOG;
59networking/dnsd.c: logmode = LOGMODE_SYSLOG;
Denis Vlasenko4221e902009-03-11 15:07:44 +000060networking/ftpd.c: logmode = LOGMODE_NONE;
Denis Vlasenkoa19e6492009-03-11 14:40:00 +000061networking/ftpd.c: logmode |= LOGMODE_SYSLOG;
62networking/inetd.c: logmode = LOGMODE_SYSLOG;
63networking/isrv_identd.c: logmode = LOGMODE_SYSLOG;
64networking/telnetd.c: logmode = LOGMODE_SYSLOG;
65networking/udhcp/dhcpc.c: logmode = LOGMODE_NONE;
66networking/udhcp/dhcpc.c: logmode |= LOGMODE_SYSLOG;
67networking/udhcp/dhcpc.c: logmode &= ~LOGMODE_STDIO;
68networking/udhcp/dhcpd.c: logmode = LOGMODE_NONE;
69networking/udhcp/dhcpd.c: logmode |= LOGMODE_SYSLOG;
70networking/zcip.c: logmode |= LOGMODE_SYSLOG;
71
72
Denis Vlasenko4221e902009-03-11 15:07:44 +000073These daemons never auto-background and never log to syslog:
Denis Vlasenkoa19e6492009-03-11 14:40:00 +000074
75lpd - inetd service. Has nothing to log so far, though
76dhcprelay - standard behavior
77inotifyd - standard behavior
78runsv - standard behavior
79runsvdir - standard behavior
80svlogd - standard behavior
81tcpsvd, udpsvd - standard behavior
82tftpd - standard behavior
83
84
85Non-daemons (seems to be use syslog for a good reason):
86
87networking/nameif.c: logmode |= LOGMODE_SYSLOG;
88loginutils/chpasswd.c: logmode = LOGMODE_BOTH;
89loginutils/chpasswd.c: logmode = LOGMODE_STDIO;
90loginutils/getty.c: logmode = LOGMODE_BOTH;
91loginutils/getty.c: logmode = LOGMODE_NONE;
92loginutils/passwd.c: logmode = LOGMODE_STDIO;
93loginutils/passwd.c: logmode = LOGMODE_BOTH;
94loginutils/sulogin.c: logmode = LOGMODE_SYSLOG; (used if stdio isn't a tty)
95loginutils/sulogin.c: logmode = LOGMODE_BOTH;
96util-linux/mount.c: logmode = LOGMODE_SYSLOG; (used in a backgrounded NFS mount helper)