Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Debian SysV init script for LSB pidofproc behavior #120

Merged
merged 1 commit into from
Feb 12, 2017

Conversation

http-418
Copy link
Contributor

The current version of the sysv/debian template is breaking on Ubuntu 14.04. The pidofproc function defined in /lib/lsb/init-functions appears to only work when taking a pathname argument (described in LSB 3.0.0)

How to re-create: Attempt bash -x /etc/init.d/kafka stop or bash -x /etc/init.d/kafka restart on Ubuntu 14.04, and you will receive an error on STDERR:

+ pidofproc /var/run/kafka.pid ''
+ local pidfile base status specified pid OPTIND
+ pidfile=
+ specified=
+ OPTIND=1
+ getopts p: opt
+ shift 0
+ '[' 2 -ne 1 ']'
+ echo '/etc/init.d/kafka: invalid arguments'
/etc/init.d/kafka: invalid arguments

This patch fixes this issue.

@mthssdrbrg
Copy link
Contributor

mthssdrbrg commented Jan 28, 2017

So this works on 14.04 but breaks on versions < 14.04?

@mthssdrbrg
Copy link
Contributor

Did some digging on Debian 7.8 and Ubuntu 14.04, and the pidofproc functions are similar in what arguments they take, but the one on Ubuntu requires there to be exactly one positional argument, whereas the Debian one doesn't do any validation.
What they do have in common is that they both take a -p parameter, with a path to a pidfile, which is probably the solution that should be used. Also, it's just pure coincidence that the stop function actually does something useful on Debian :)

@http-418
Copy link
Contributor Author

The documented behavior in LSB 3.0 is that 'pidofproc -p' should work, but it doesn't.

I have been testing on Debian 8, Ubuntu 12.04, and Ubuntu 14.04. 'pidofproc pathname' works on all three. 'pidofproc -p' fails silently Debian 8 and Ubuntu 12.04. On Ubuntu 14.04, 'pidofproc -p' returns an actual error.

I am pretty sure the patch in this PR is the most portable solution, since it conforms to the documented behavior and it works on actual systems in the wild.

@mthssdrbrg mthssdrbrg merged commit 721972c into sous-chefs:master Feb 12, 2017
@mthssdrbrg
Copy link
Contributor

Fair enough, thanks a lot for the contribution @http-418.

@lock
Copy link

lock bot commented Apr 25, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Apr 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants