Bug#664621: status option returns with exit code 4 and 'could not access PID file for [...]'

Didier Raboud <[email protected]>
Newsgroups gmane.linux.debian.devel.lsb
Organization Debian - The Universal OS
Message-ID <201203191735.25524.odyx__35547.9261059829$1332175165$gmane$org@debian.org>
tags 664621 +patch
thanks

Hi Mika, and thanks for your bugreport,

Le lundi, 19 mars 2012 13.49:24, Michael Prokop a écrit :
> I'd expect to get exit code 3 and a less misleading error message
> as the init script/program should be aware of its own state in such
> a situation.

Agreed.

What about the attached patch ? As far as I can tell from local testing, it 
solves the issue you report.
 
> I'm tempted to call this an RC bug, but leaving that decision to the
> package maintainer(s).

I respectfully disagree, but will nevertheless make sure to have a fix for 
this issue uploaded soon.

Cheers,

OdyX
0001-Make-init-functions-status_of_proc-return-the-LSB-do.patch (text/x-patch, 1.2 KB)
From 23c14db17c85676192c2952637bfe39a10294ba2 Mon Sep 17 00:00:00 2001
From: Didier Raboud <[email protected]>
Date: Mon, 19 Mar 2012 17:09:40 +0100
Subject: [PATCH] Make init-functions' status_of_proc return the LSB-documented 3 on inexistant pidfiles.

This enhances the 13f38d30a823afc5841fd17ee405c6ebff2af1ac commit by
additionally taking the potential inexistance of pidfiles into account.

Closes: #664621
Reported-by: Michael Prokop <[email protected]>
Signed-off-by: Didier Raboud <[email protected]>
---
 init-functions |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/init-functions b/init-functions
index d5b6971..35ed7eb 100644
--- a/init-functions
+++ b/init-functions
@@ -82,6 +82,7 @@ pidofproc () {
     fi
 
     if [ -n "${pidfile:-}" ]; then
+     if [ -e "$pidfile" ]; then
       if [ -r "$pidfile" ]; then
         read pid < "$pidfile"
         if [ -n "${pid:-}" ]; then
@@ -98,6 +99,9 @@ pidofproc () {
       else
         return 4 # pid file not readable, hence status is unknown.
       fi
+     else
+       return 3 # pid file doesn't exist, program probably stopped
+     fi
     fi
     if [ -x /bin/pidof ] && [ ! "$specified" ]; then
         status="0"
-- 
1.7.2.5
signature.asc (application/pgp-signature, 665 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iQGcBAABCAAGBQJPZ2BFAAoJEIvPpx7KFjRVfJ0L/3ICKsQS7/IpmcB3IFQTdQij
QCiAlg2yur8y5ITDnD3y1RpsTPc7SgoU9I589fMsaCJ0UI1MnE+0G/Q4t3xz5Xn5
gkxnW/jekpa3BT7sCjOfEG4Rsju02uVgtCz1vocItw2Ep4ciJpH9+Srnxmtd6aN+
VtNJjz+xMoJgeuRHlh/OCnYmTNpU4pQRkF37BoHjc25OQaCPcesyIdJoVVT7vfMc
tiviANt+4hxP3n3hbp//WGyhu5VBXeh6+k8LZweZM+qZXqVOcihA4Swz20oMSxxZ
mPofleqxTLvpqpzCvcSYnCFd5Vcjgq6dVEk57vRVyZUSI/+f+4KtR8BeWcwgctfu
mQIKcjddayMmVmvV9L0+efUQIqUCsO7Dd209g4RVgsTas3xBVkRVqHGyiapAn27E
vU8nGx7oyKGhBW9/QcHE6Zg5oP6p4oh1uA7c3wwlNBk+nyIovmH8P4AJVBjVZmgo
FZYsq9kbJWDEMC7BkhrmfAGdvXzLrAiUwFolKasgEg==
=vPHM
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.