Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 769179 - service_started always returns 1 in stop_pre context
Summary: service_started always returns 1 in stop_pre context
Status: CONFIRMED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: OpenRC (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: OpenRC Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-02-07 02:00 UTC by kfm
Modified: 2023-01-29 03:07 UTC (History)
1 user (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description kfm 2021-02-07 02:00:59 UTC
I noticed this while writing a runscript that incorporates the following stop_pre function:-

stop_pre() {
   if [ "$RC_CMD" = restart ] && service_started; then
       checkconfig
   fi
}

The problem is that the exit status value of service_started is always 1, even in the case that service is, in fact, started. This does not make sense. A stop_pre function is executed before the service is actually stopped. Therefore, I would expect service_started to to yield 0 in the case that the service is up and running.

This is as tested with both start-stop-daemon and supervise-daemon, using openrc-0.42.1-r1.
Comment 1 William Hubbs gentoo-dev 2021-03-22 23:36:31 UTC
You are correct about service_started returning 1 in the stop_pre
context. Also, stop_pre will not run if the service failed to start or
is stopped, so unless I'm missing something, you don't really need to
use service_started in the stop_pre context. If you drop service_started
from the example you show above you should be fine.

I will keep this open, but the above should work for you.

Thanks,

William