Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 88319 - init.d status should have a return value that reflects the status of the service
Summary: init.d status should have a return value that reflects the status of the service
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: All All
: High enhancement (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-07 23:41 UTC by Josh Nichols (RETIRED)
Modified: 2005-04-15 15:30 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
patch for runscript (baselaselayout-1.9.4-runscript_return.patch,873 bytes, patch)
2005-04-09 15:45 UTC, Josh Nichols (RETIRED)
Details | Diff
patch for runscript (baselayout-1.9.4-runscript_return.patch,990 bytes, patch)
2005-04-13 21:53 UTC, Josh Nichols (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Josh Nichols (RETIRED) gentoo-dev 2005-04-07 23:41:00 UTC
Using baselayout-1.9.4-r6, running /etc/init.d/<insert service> status will always have a return value of 0. It would be useful, for scripting purposes, to have it return 0 if the service is running, or non-zero if the service is not running.

A work around I'm using now:
/etc/init.d/<some service> 2>&1 | grep started > /dev/null

Fedora seems to do this currently, with its /sbin/service, and some of the redhat config tools use this to check if services are running.
Comment 1 SpanKY gentoo-dev 2005-04-08 06:20:53 UTC
1.11.x has the same behavior, this change is fine for me ...
Comment 2 Josh Nichols (RETIRED) gentoo-dev 2005-04-09 15:45:18 UTC
Created attachment 55803 [details, diff]
patch for runscript

It seems that the runscript does have the desired effect, to some extent. It
will do it when passed RC_QUIET_STDOUT is set to yes.

This patch makes it have a return value regardless of RC_QUIET_STDOUT.
Comment 3 SpanKY gentoo-dev 2005-04-09 18:15:42 UTC
committed to cvs, thanks :)
Comment 4 Josh Nichols (RETIRED) gentoo-dev 2005-04-11 18:47:34 UTC
There may be a slight problem. If you applied my patch as is, the per-init.d status() won't be called if RC_QUIET_STDOUT. This probably isn't desired, but I did it at the time because status called might call einfo and eerror. So, either status() should check RC_QUIET_STDOUT, or probably better, einfo and eerror should check RC_QUIET_STDOUT.
Comment 5 SpanKY gentoo-dev 2005-04-11 19:21:50 UTC
no, i did not use your patch as posted
Comment 6 Josh Nichols (RETIRED) gentoo-dev 2005-04-13 21:53:31 UTC
Created attachment 56225 [details, diff]
patch for runscript

It seems that eerror and einfo already take RC_QUIET_STDOUT, so those variables
don't need to be tested here. Also, if the status is detected as running, then
the   init script's status is checked, and returned.
Comment 7 SpanKY gentoo-dev 2005-04-15 15:30:25 UTC
that is true but the underlying functions treat the variable a bit differently from status() ...

status() never outputs anything if quiet is set to yes while ewarn/eerror will still output stuff