invoke-rc.d uses incorrect exit code

Bug #1511628 reported by Nathan Osman
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
sysvinit (Ubuntu)
New
Undecided
Unassigned

Bug Description

I am using invoke-rc.d on Vivid and have observed what appears to be incorrect behavior. I have a systemd service installed that is masked and I am attempting to use invoke-rc.d to obtain its status.

However, the exit code is 0, which falsely suggests that the service is running. If I run "systemctl status myservice" directly for the masked service, the exit code is 3, as expected.

This makes it impossible to determine if the service is in fact running without resorting to systemd commands. I'm developing a package that runs on releases that use init and releases that use systemd. The packaging includes an init script and a systemd unit file. I need an "init-agnostic" command for restarting the service in the .logrotate file.

I dug a bit into the source code and found that line 407 contains "exit 0". I don't understand why anyone would want the return code for a running service and a masked service to be identical. I assume this is a bug.

ProblemType: Bug
DistroRelease: Ubuntu 15.04
Package: sysv-rc 2.88dsf-53.2ubuntu12
ProcVersionSignature: Ubuntu 3.19.0-30.34-generic 3.19.8-ckt6
Uname: Linux 3.19.0-30-generic x86_64
ApportVersion: 2.17.2-0ubuntu1.5
Architecture: amd64
CurrentDesktop: Unity
Date: Thu Oct 29 23:37:05 2015
InstallationDate: Installed on 2015-06-01 (150 days ago)
InstallationMedia: Ubuntu 15.04 "Vivid Vervet" - Release amd64 (20150422)
PackageArchitecture: all
SourcePackage: sysvinit
UpgradeStatus: Upgraded to vivid on 2015-10-22 (7 days ago)

Revision history for this message
Nathan Osman (george-edison55) wrote :
Revision history for this message
Steve Langasek (vorlon) wrote :

invoke-rc.d is an interface for package maintainer scripts to manipulate services, as described in Debian policy; it is almost never the correct interface for other tools to use. Returning 0 when a service is not restarted because masked is the correct behavior for this interface.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.