# /etc/init.d/tgtd status; ps -C tgtd tgtd is NOT running. PID TTY TIME CMD 3056 ? 00:00:00 tgtd 3057 ? 00:00:00 tgtd The reason for this seems the way /etc/init.d/tgtd checks for number of running tgtd processes: status() { # Don't name this script "tgtd"... TGTD_PROC=$(ps -C tgtd | grep -c tgtd) if [ "$TGTD_PROC" -eq 2 ] ; then echo "tgtd is running. Run 'tgt-admin -s' to see detailed target info." else echo "tgtd is NOT running." fi } Note the comment.
I ran into this tonight, so it's still an issue. As the submitter pointed out, the status checks for two running processes that match 'tgtd', which fails when the third (grep) process runs. Since tgtd doesn't create a pid file, a slightly better test might be "Are two processes running whose names start with tgtd, one of which is the other's parent?" We could even start the process as "tgtd --debug 0" to make the text match better. The "--debug 0" would be a no-op, and would have to be omitted if the user specified an actual --debug in /etc/conf.d/tgtd. Unrelatedly, the stop command fails to stop the daemon, and I question the assumption in the comments "tgtd will exit if all targets were removed". The whole script could probably use review.
Created attachment 381178 [details, diff] tgtd init patch Proposed fix. Uses pidof (from procps, a base package). Test case: 1. /etc/init.d/tgtd start 2. /etc/init.d/tgtd status Expect: Messaging that tgtd is running Actual: Messaging "tgtd is NOT running", ps shows tgtd processes
I've kept on having problems such as this one with tgtd init scripts (for 1.5 years).
I'm gonna work on it sometime this week(end).
Fixed in 1.0.60