[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

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



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
From 23c14db17c85676192c2952637bfe39a10294ba2 Mon Sep 17 00:00:00 2001
From: Didier Raboud <odyx@debian.org>
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 <mika@debian.org>
Signed-off-by: Didier Raboud <odyx@debian.org>
---
 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

Attachment: signature.asc
Description: This is a digitally signed message part.


Reply to: