Ticket #164 (closed defect: fixed)
Opened 17 months ago
Last modified 16 months ago
start-stop-daemon - problem indentifying process by name
Reported by: | Vilkata <vgetov@gmail.com> | Owned by: | roy |
---|---|---|---|
Priority: | major | Milestone: | |
Component: | rc | Version: | 0.4 |
Keywords: | Cc: |
Description
The problem:
vgetov openrc-0.4.3 # start-stop-daemon --stop -t --name statclld
* start-stop-daemon: no matching processes found
vgetov openrc-0.4.3 # start-stop-daemon --version
start-stop-daemon (OpenRC) 0.4.3 (Gentoo Linux)
vgetov openrc-0.4.3 # ps ax | grep stat
17767 ? Ss 0:00 statclld
vgetov openrc-0.4.3 #
dogmatix:~# start-stop-daemon -t --stop --name statclld
Would send signal 15 to 9470.
dogmatix:~# ps ax | grep statclld
9470 ? Ss 0:00 statclld
dogmatix:~# start-stop-daemon --version
start-stop-daemon 1.13.11+gentoo
I have a daemon (statclld) written in perl which is managed without any problem on baselayout-1 based system but on baselayout-2 the start-stop-daemon tool is unable to recognize the running process.
The line below in my script caused the problem:
$0 =~ s/.*\/; # Set process name to filename without path
When removing this code the functionality of the start-stop-daemon is as expected.
Think this is a bug in openrc implementation of the start-stop-daemon tool.
Regards,
Vilkata.
Attachments
Change History
comment:2 in reply to: ↑ 1 Changed 16 months ago by Vilkata <vgetov@gmail.com>
Replying to roy:
Matching interpreted daemons is tricky :)
Can you attach a test case for this?
The perl script just needs to daemonise in the same way and say resident doing nothing.
Then I can try fix s-s-d for you.
Here is the fragment in perl which daemonise the script:
$0 =~ s/.*\///; # Set process name to filename without path $|=1; # Flush buffers and desable I/O buffering chdir '/' or die "Can't chdir to /: $!"; umask 0; open STDIN, '/dev/null' or die "Can't read /dev/null: $!"; open STDOUT, '>/dev/null' or die "Can't write to /dev/null: $!"; defined ( my $pid = fork ) or die "Can't fork: $!"; if ( $pid != 0 ) { exit; }; POSIX::setsid() or die "Can't start a new session: $!";
The line above
$0 =~ s/.*\///;
simply sets the name of the process to be just the name of the script, in my case "statclld".
An example:
ps ax | grep statclld
32618 ? Ss 0:19 statclld
If I do not modify the $0 variable here is the way it looks in the process list:
ps ax | grep statclld
32620 ? Ss 0:19 /usr/bin/perl -w /usr/local/sbin/statclld
The s-s-d tool works fine in second scenario. The reason I opened this ticket is that the behavior of the s-s-d is different in openrc implementation. Most probably you want to follow some standards which in this case are not satisfied.
comment:3 follow-up: ↓ 4 Changed 16 months ago by roy
It looks like the current SVN code works just fine - can you verify this?
roy@uberpc ~ $ /sbin/start-stop-daemon --verbose --stop --name statclld * Will stop statclld * start-stop-daemon: no matching processes found roy@uberpc ~ $ ./statclld start roy@uberpc ~ $ /sbin/start-stop-daemon --verbose --stop --name statclld * Will stop statclld * Sending signal 15 to PID 4055... [ok] roy@uberpc ~ $ /sbin/start-stop-daemon --verbose --stop --name statclld * Will stop statclld * start-stop-daemon: no matching processes found roy@uberpc ~ $
comment:4 in reply to: ↑ 3 Changed 16 months ago by Vilkata <vgetov@gmail.com>
My distribution behaves different, but the name resolution of s-s-d does not work with the SVN version of the openrc
vgetov rc # ./start-stop-daemon --version start-stop-daemon (OpenRC) 0.4.3-svn-1538 vgetov rc # ps ax | grep statclld 3142 ? Ss 0:02 statclld vgetov rc # ./start-stop-daemon --verbose --stop --name statclld * Will stop statclld * Will stop processes of `/usr/bin/perl -w' * start-stop-daemon: no matching processes found
Here is a short description of my platform:
vgetov rc # uname -a Linux vgetov 2.6.27-gentoo-r4 #5 Tue Apr 7 17:13:03 EEST 2009 i686 Intel(R) Pentium(R) D CPU 2.80GHz GenuineIntel GNU/Linux vgetov rc # eselect profile list Available profile symlink targets: [1] default/linux/x86/2008.0 * [2] default/linux/x86/2008.0/desktop [3] default/linux/x86/2008.0/developer [4] default/linux/x86/2008.0/server [5] hardened/x86 [6] selinux/2007.0/x86 [7] selinux/2007.0/x86/hardened [8] hardened/linux/x86 vgetov rc # /lib/libc.so.6 GNU C Library stable release version 2.6, by Roland McGrath et al. Copyright (C) 2007 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Compiled by GNU CC version 4.2.0 (Gentoo 4.2.0 p1.4). Compiled on a Linux >>2.6.22-gentoo-r1<< system on 2007-07-26. Available extensions: C stubs add-on version 2.1.2 crypt add-on version 2.1 by Michael Glad and others Gentoo patchset 1.4 GNU Libidn by Simon Josefsson Native POSIX Threads Library by Ulrich Drepper et al Support for some architectures added on, not maintained in glibc core. BIND-8.2.3-T5B For bug reporting instructions, please see: <http://www.gnu.org/software/libc/bugs.html>.
comment:5 Changed 16 months ago by roy
- Status changed from new to closed
- Resolution set to fixed
OK, the issue was that we found the statclld program in $PATH and tried to match interpreter.
I can see why this is an issue, so I've added a flag -i, --interpreted to enable this - it's now disabled by default
Fixed in r1539
Matching interpreted daemons is tricky :)
Can you attach a test case for this?
The perl script just needs to daemonise in the same way and say resident doing nothing.
Then I can try fix s-s-d for you.