1 --- ./rc.d/init.d/functions.orig Tue Oct 29 18:08:50 2002
2 +++ ./rc.d/init.d/functions Tue Oct 29 18:02:56 2002
4 # Marek Obuchowicz <elephant@pld.org.pl>
5 # Arkadiusz Mi¶kiewicz <misiek@pld.org.pl>
6 # Micha³ Kochanowicz <mkochano@pld.org.pl>
7 +# Mariusz Mazur <mmazur@pld.org.pl>
9 # First set up a default search path.
10 export PATH="/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin"
15 +# A function to filter out pids that are not in current chroot.
19 + # We don't test syntax since we can get zero parameters
22 + while [ $# -gt 0 ]; do
23 + rewt=$(resolvesymlink /proc/$1/root)
24 + if [ -n "$rewt" ]; then
25 + if [ "$rewt" = "/" ] || \
26 + [ "$rewt" = "/usr/share/empty" ] || \
27 + [ "$rewt" = "/var/lib/named" ] || \
28 + [ "$rewt" = "$CHROOT_TO_DIR" ]; then
29 + filteredpids="$filteredpids $1"
38 # A function to find the pid of a program.
42 # First try "/var/run/*.pid" files
43 if [ -f /var/run/$1.pid ] ; then
44 pid=$(head -1 /var/run/$1.pid)
45 + pid=$(filterchrooted $pid)
46 if [ -n "$pid" ] ; then
52 pid=$(pidof -o $$ -o $PPID -o %PPID -x $1)
53 + pid=$(filterchrooted $pid)
54 if [ -n "$pid" ] ; then
59 # Finally try to extract it from ps
60 - ps ax | awk 'BEGIN { prog=ARGV[1]; ARGC=1 }
61 + filterchrooted `ps ax | awk 'BEGIN { prog=ARGV[1]; ARGC=1 }
62 { if ((prog == $5) || (("(" prog ")") == $5) ||
63 (("[" prog "]") == $5) ||
64 - ((prog ":") == $5)) { print $1 ; exit 0 } }' $1
65 + ((prog ":") == $5)) { print $1 ; exit 0 } }' $1`
72 pid=$(pidof -o $$ -o $PPID -o %PPID -x $daemon)
73 + pid=$(filterchrooted $pid)
74 if [ -n "$pid" ] ; then
75 nls "%s (pid %s) is running..." "$daemon" "$pid"
78 { if ((prog == $5) || (("(" prog ")") == $5) ||
79 (("[" prog "]") == $5) ||
80 ((prog ":") == $5)) { print $1 ; exit 0 } }' $1`
81 + pid=$(filterchrooted $pid)
82 if [ "$pid" != "" ] ; then
83 nls "%s (pid %s) is running..." "$daemon" "$pid"
86 # Next try "/var/run/*.pid" files
87 if [ -f /var/run/$daemon.pid ] ; then
88 pid=$(head -1 /var/run/$1.pid)
89 + pid=$(filterchrooted $pid)
90 if [ -n "$pid" ] ; then
91 nls "%s dead but pid file exists" "$1"