#587675 apcupsd: init script should report errors

Package:
apcupsd
Source:
apcupsd
Description:
APC UPS Power Management (daemon)
Submitter:
Martin von Wittich
Date:
2010-06-30 19:36:04 UTC
Severity:
normal
#587675#5
Date:
2010-06-30 18:29:51 UTC
From:
To:
When starting apcupsd via init script the init script fails to report errors.
E.g. if you don't have a UPS connected to the computer apcupsd won't start, but
the init script will report a success condition nonetheless.

The behaviour is similar when starting apcupsd directly; it will immediately
fork and the original process will exit without an error message. The forked
process will try to connect to the UPS in the background; when this fails, it
will die silently after a few seconds. Only if I increase the debug level an
error message appears after a while, but due to the fork apcupsd still returns
with exit code 0 signalling success:

iserv ~ # apcupsd -d 100; echo $?
0.000 apcupsd: apcupsd.c:219 Options parsed.
0.004 apcupsd: apcupsd.c:242 Config file /etc/apcupsd/apcupsd.conf processed.
0.004 apcupsd: newups.c:102 write_lock at drivers.c:208
0.004 apcupsd: drivers.c:210 Looking for driver: usb
0.004 apcupsd: drivers.c:214 Driver dumb is configured.
0.004 apcupsd: drivers.c:214 Driver apcsmart is configured.
0.004 apcupsd: drivers.c:214 Driver net is configured.
0.004 apcupsd: drivers.c:214 Driver usb is configured.
0.004 apcupsd: drivers.c:217 Driver usb found and attached.
0.004 apcupsd: newups.c:108 write_unlock at drivers.c:234
0.004 apcupsd: drivers.c:236 Driver ptr=0x806c890
0.004 apcupsd: apcupsd.c:261 Attached to driver: usb
0.004 apcupsd: newups.c:102 write_lock at linux-usb.c:582
0
iserv ~ #
10.039 apcupsd: newups.c:108 write_unlock at linux-usb.c:601
apcupsd FATAL ERROR in linux-usb.c at line 609
Cannot find UPS device --
For a link to detailed USB trouble shooting information,
please see <http://www.apcupsd.com/support.html>.
10.039 apcupsd: apclog.c:62 apcupsd FATAL ERROR in linux-usb.c at line 609
Cannot find UPS device --
For a link to detailed USB trouble shooting information,
please see <http://www.apcupsd.com/support.html>.

10.039 apcupsd: newups.c:102 write_lock at linux-usb.c:631
10.039 apcupsd: newups.c:108 write_unlock at linux-usb.c:638
10.039 apcupsd: apclog.c:62 apcupsd error shutdown completed

I realize that apcupsd probably forks so the user doesn't have to wait, but in
this case I would prefer it to block until it has determined it can actually
connect, and only then return with exit code 0, and with a non-zero exit code
otherwise. This would be especially useful for scripting purposes.