| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | # $NetBSD: rc.subr,v 1.86 2010/09/26 18:37:14 apb Exp $ | | 1 | # $NetBSD: rc.subr,v 1.87 2011/06/09 14:52:01 christos Exp $ |
2 | # | | 2 | # |
3 | # Copyright (c) 1997-2004 The NetBSD Foundation, Inc. | | 3 | # Copyright (c) 1997-2004 The NetBSD Foundation, Inc. |
4 | # All rights reserved. | | 4 | # All rights reserved. |
5 | # | | 5 | # |
6 | # This code is derived from software contributed to The NetBSD Foundation | | 6 | # This code is derived from software contributed to The NetBSD Foundation |
7 | # by Luke Mewburn. | | 7 | # by Luke Mewburn. |
8 | # | | 8 | # |
9 | # Redistribution and use in source and binary forms, with or without | | 9 | # Redistribution and use in source and binary forms, with or without |
10 | # modification, are permitted provided that the following conditions | | 10 | # modification, are permitted provided that the following conditions |
11 | # are met: | | 11 | # are met: |
12 | # 1. Redistributions of source code must retain the above copyright | | 12 | # 1. Redistributions of source code must retain the above copyright |
13 | # notice, this list of conditions and the following disclaimer. | | 13 | # notice, this list of conditions and the following disclaimer. |
14 | # 2. Redistributions in binary form must reproduce the above copyright | | 14 | # 2. Redistributions in binary form must reproduce the above copyright |
| @@ -238,30 +238,37 @@ _find_processes() | | | @@ -238,30 +238,37 @@ _find_processes() |
238 | if [ $# -ne 3 ]; then | | 238 | if [ $# -ne 3 ]; then |
239 | err 3 'USAGE: _find_processes procname interpreter psargs' | | 239 | err 3 'USAGE: _find_processes procname interpreter psargs' |
240 | fi | | 240 | fi |
241 | _procname=$1 | | 241 | _procname=$1 |
242 | _interpreter=$2 | | 242 | _interpreter=$2 |
243 | _psargs=$3 | | 243 | _psargs=$3 |
244 | | | 244 | |
245 | _pref= | | 245 | _pref= |
246 | _procnamebn=${_procname##*/} | | 246 | _procnamebn=${_procname##*/} |
247 | if [ $_interpreter != "." ]; then # an interpreted script | | 247 | if [ $_interpreter != "." ]; then # an interpreted script |
248 | read _interp < ${_chroot:-}/$_procname # read interpreter name | | 248 | read _interp < ${_chroot:-}/$_procname # read interpreter name |
249 | _interp=${_interp#\#!} # strip #! | | 249 | _interp=${_interp#\#!} # strip #! |
250 | set -- $_interp | | 250 | set -- $_interp |
| | | 251 | if [ $1 = "/usr/bin/env" ]; then |
| | | 252 | shift |
| | | 253 | set -- $(type $1) |
| | | 254 | shift $(($# - 1)) |
| | | 255 | _interp="${1##*/} $_procname" |
| | | 256 | else |
| | | 257 | _interp="$* $_procname" |
| | | 258 | fi |
251 | if [ $_interpreter != $1 ]; then | | 259 | if [ $_interpreter != $1 ]; then |
252 | warn "\$command_interpreter $_interpreter != $1" | | 260 | warn "\$command_interpreter $_interpreter != $1" |
253 | fi | | 261 | fi |
254 | _interp="$* $_procname" # cleanup spaces, add _procname | | | |
255 | _interpbn=${1##*/} | | 262 | _interpbn=${1##*/} |
256 | _fp_args='_argv' | | 263 | _fp_args='_argv' |
257 | _fp_match='case "$_argv" in | | 264 | _fp_match='case "$_argv" in |
258 | ${_interp}|"${_interp} "*|"${_interpbn}: "*${_procnamebn}*)' | | 265 | ${_interp}|"${_interp} "*|"${_interpbn}: "*${_procnamebn}*)' |
259 | else # a normal daemon | | 266 | else # a normal daemon |
260 | _fp_args='_arg0 _argv' | | 267 | _fp_args='_arg0 _argv' |
261 | _fp_match='case "$_arg0" in | | 268 | _fp_match='case "$_arg0" in |
262 | $_procname|$_procnamebn|${_procnamebn}:|"(${_procnamebn})")' | | 269 | $_procname|$_procnamebn|${_procnamebn}:|"(${_procnamebn})")' |
263 | fi | | 270 | fi |
264 | | | 271 | |
265 | _proccheck=' | | 272 | _proccheck=' |
266 | ps -o "pid,command" '"$_psargs"' | | | 273 | ps -o "pid,command" '"$_psargs"' | |
267 | while read _npid '"$_fp_args"'; do | | 274 | while read _npid '"$_fp_args"'; do |