“OMG ALARM ALARM!” a coworker bust through the door claiming I or someone broke the code keeping track of one of the services that are running. That’s unpossible I proclaim. The code in question is this:
if ! pidof service;then
service | logger
fi
but we have multiple instances of service running. Sure, we use busybox, an older version. Bet there’s a bug there, I have to see it though.
output=$(pidof service 2>&1)
status=$?
if ! (($status == 0)); then
echo "$(date) pidof service failed: status: $status output: $output"
fi
and what do I get?
Mon Jan 13 12:04:33 CET 2008 pidof service failed: error: 1 output: 30740
Fine, it’s busybox. Must be.. We patch it to exit with 47 if any malloc etc fail and 66 if the actual pidof code fails.
Mon Jan 13 14:46:13 CET 2008 pidof service failed: error: 1 output: 30740 10178
OK? FINE! We replace it with sysvinit-utils pidof..
Mon Jan 14 08:59:51 CET 2008 pidof service failed: error: 1 output: 30740 10178 2548
ARGH! .. …