Skip to content

[JENKINS-11306] Debian init script: status command exit code is always 0 #16151

Closed

Description

@jenkins-infra-bot

Under debian Lenny, the /etc/init.d/jenkins status script always exit with return code 0, even it the service is not running. According to LSB standard, the return code should be the following:

  • 0 program is running or service is OK;
  • 1 program is dead and /var/run pid file exists;
  • 3 program is not running.

Found on https://fedoraproject.org/wiki/FCNewInit/Initscripts#Init_Script_Actions as official LSB website is currently down.

This fixed status code is quite annoying if we rely on the init script for monitoring purpose.


Originally reported by rborer, imported from: Debian init script: status command exit code is always 0
  • status: Resolved
  • priority: Minor
  • component(s): core
  • resolution: Fixed
  • resolved: 2012-01-18T00:18:47+00:00
  • votes: 0
  • watchers: 1
  • imported: 2025-11-24
Raw content of original issue

Under debian Lenny, the /etc/init.d/jenkins status script always exit with return code 0, even it the service is not running. According to LSB standard, the return code should be the following:

  • 0 program is running or service is OK;
  • 1 program is dead and /var/run pid file exists;
  • 3 program is not running.

Found on https://fedoraproject.org/wiki/FCNewInit/Initscripts#Init_Script_Actions as official LSB website is currently down.

This fixed status code is quite annoying if we rely on the init script for monitoring purpose.

  • environment: Debian Lenny (5.0.9), Jenkins 1.434

Activity

  1. jenkins-infra-bot commented on Oct 12, 2011

    @jenkins-infra-bot
    Author
    oldelvet:
    • Original comment link
    • Raw content of original comment:

      The Debian Wiki collects together relevant information at http://wiki.debian.org/LSBInitScripts

      In particular the final comment says that Debian policy diverges from LSB in that Debian always uses return code 0.

      What is a "proper" exit status code?

      Looking at #208010, this seems rather controversial. Non-zero exit codes might even cause breakage, and the LSB conflicts with Debian policy here.

      There is much discussion at http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=208010

      It looks to me like current Debian behaviour/best practice is to return 0 as Jenkins currently does.

    The Debian Wiki collects together relevant information at
    http://wiki.debian.org/LSBInitScripts

    In particular the final comment says that Debian policy diverges from LSB in that Debian always uses return code 0.

    What is a "proper" exit status code?

    Looking at #208010, this seems rather controversial. Non-zero exit codes might even cause breakage, and the LSB conflicts with Debian policy here.

    There is much discussion at
    http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=208010

    It looks to me like current Debian behaviour/best practice is to return 0 as Jenkins currently does.

  2. jenkins-infra-bot commented on Oct 12, 2011

    @jenkins-infra-bot
    Author
    rborer:
    • Original comment link
    • Raw content of original comment:

      The situation of LSB compliance in Debian is indeed quite unclear, there is clearly no Debian way for the status command. Now in my use-case, I would find quite convenient to have a proper exit code if the service is not running, and I am probably not the only one in that case.

      Do you see any obvious case where this could have side effect?

      In the end, it looks like its up to the maintainer of the package to decide which way to go. I have manually patched the script on my Jenkins installations and my patch is not erased after each package upgrade, if anyone wants to apply the same patch, I opened a pull request: [JENKINS-11306] Debian init script: return a proper status code when Jenkins is not running. #281

    The situation of LSB compliance in Debian is indeed quite unclear, there is clearly no Debian way for the status command. Now in my use-case, I would find quite convenient to have a proper exit code if the service is not running, and I am probably not the only one in that case.

    Do you see any obvious case where this could have side effect?

    In the end, it looks like its up to the maintainer of the package to decide which way to go. I have manually patched the script on my Jenkins installations and my patch is not erased after each package upgrade, if anyone wants to apply the same patch, I opened a pull request: #281

  3. jenkins-infra-bot commented on Nov 8, 2011

    @jenkins-infra-bot
    Author
    kohsuke:
    • Original comment link
    • Raw content of original comment:

      I looked at the debian bug #208010 and my reading is that the only disputed point is on a narrow point of "what exit code to return if the package is removed but not purged" (see msg #233 for example).

      I further looked /etc/init.d/ssh, which uses the standard /lib/lsb/init-functions code. The pidofproc() function in this script implements the same set of exit code as the proposed change.

      Furthermore, it's easy to ignore the status code if the caller doesn't care if we integrate this change, yet there's no easy workaround for the caller if we leave it out.

      So on the whole, I'm going to merge this change in.

    I looked at the debian bug #208010 and my reading is that the only disputed point is on a narrow point of "what exit code to return if the package is removed but not purged" (see msg #233 for example).

    I further looked /etc/init.d/ssh, which uses the standard /lib/lsb/init-functions code. The pidofproc() function in this script implements the same set of exit code as the proposed change.

    Furthermore, it's easy to ignore the status code if the caller doesn't care if we integrate this change, yet there's no easy workaround for the caller if we leave it out.

    So on the whole, I'm going to merge this change in.

  4. jenkins-infra-bot commented on Nov 8, 2011

    @jenkins-infra-bot
    Author
    scm_issue_link:

    Code changed in jenkins
    User: Reynald Borer
    Path:
    changelog.html
    debian/debian/jenkins.init
    http://jenkins-ci.org/commit/jenkins/2f9fff923981c7aeccca9ca88482062a7e578a24
    Log:
    JENKINS-11306 Debian init script: return a proper status code when Jenkins is not running.

  5. jenkins-infra-bot commented on Nov 8, 2011

    @jenkins-infra-bot
    Author
    scm_issue_link:

    Code changed in jenkins
    User: Reynald Borer
    Path:
    debian/debian/jenkins.init
    http://jenkins-ci.org/commit/jenkins/2cc316cb6e170b238598d0f38a8d7e7fe87c989e
    Log:
    JENKINS-11306 Debian init script: return a proper status code when Jenkins is not running.

  6. jenkins-infra-bot commented on Nov 8, 2011

    @jenkins-infra-bot
    Author
    dogfood:

    Integrated in jenkins_main_trunk #1274
    JENKINS-11306 Debian init script: return a proper status code when Jenkins is not running.

    Kohsuke Kawaguchi : 2f9fff923981c7aeccca9ca88482062a7e578a24
    Files :

    • debian/debian/jenkins.init
    • changelog.html
  7. jenkins-infra-bot commented on Apr 3, 2015

    @jenkins-infra-bot
    Author
    scm_issue_link:

    Code changed in jenkins
    User: Reynald Borer
    Path:
    debian/jenkins.init
    http://jenkins-ci.org/commit/packaging/69e2d324eb23122ddf35a4b687c5bc0589b15c23
    Log:
    JENKINS-11306 Debian init script: return a proper status code when Jenkins is not running.

    Originally-From: jenkins-ci.org/commit/core/2f9fff923981c7aeccca9ca88482062a7e578a24

  8. removed
    bugFor changelog: Minor bug. Will be listed after features
    on Nov 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions