Subject: Re: rc.subr problem with interpreted daemons
To: Ed Ravin <eravin@panix.com>
From: Luke Mewburn <lukem@wasabisystems.com>
List: tech-userlevel
Date: 03/20/2002 23:21:32
On Tue, Mar 19, 2002 at 12:19:29PM -0500, Ed Ravin wrote:
| Luke Mewburn writes:
| [...]
| > The intention is to
| > support "interpreters" for arbitrary rc.d commands, such that
| > check_process() and check_pidfile() do the right thing.
| >
| > I've been considering the "cleanest" way to do this;
| [...]
| > My current thoughts are along the lines of supporting two more
| > optional variables:
| > interpreter interpreter-name
| > command_shift # of args to shift to find the command
|
| How about a user-supplied match pattern or regexp instead? Then you
| have only one parameter in the rc.d script instead of two. Also, there's
| the possibility of false positives when matching this way - consider:
|
| frog_interpreter=/bin/sh
| frog_command_shift=2
|
| Would match both:
|
| /bin/sh -c frog
|
| and
|
| /bin/sh ./myscript frog
|
| Which would cause problems if you didn't have a pidfile.
I've implemented a more general solution, which I'll commit tomorrow.
If $command_interpreted != "", then the first line of $command is
parsed to build up a command string and that's searched for instead.
For example, if the script "frog" has:
#! /bin/sh -e
then check_{process,pidfile}() will match:
/bin/sh -e frog
/bin/sh -e frog more_args
but won't match
/bin/sh -e froglegs
The rc.d script writer just needs to set command_interpreted=foo.
I'm "sleeping" on the code before commit, but it seems to work as
expected in my testing.
As part of the work, I've cleaned up how check_process() and
check_pidfile() operate, so that they share a common private function
for the majority of their operation.
Luke.
--
Luke Mewburn <lukem@wasabisystems.com> http://www.wasabisystems.com
Luke Mewburn <lukem@netbsd.org> http://www.netbsd.org
Wasabi Systems - NetBSD hackers for hire
NetBSD - the world's most portable UNIX-like operating system