sh coredump through rc.subr

Tobias Roth roth at iam.unibe.ch
Wed Jul 30 07:45:47 PDT 2003


i just managed to get an sh coredump with an rc.d/ script of mine.
here is part of the output of /etc/rc.d/test stop :

/etc/rc.d/test: DEBUG: run_rc_command: evaluating :().
Loading configuration files.
Node type = 15
pid 5183 (sh), uid 0: exited on signal 11 (core dumped)
zsh: segmentation fault (core dumped)  /etc/rc.d/test stop

the 'Node type' message comes from sh's eval.c function.  my rc.d/test
is attached.

the shell dies after the last command from test_stop(), but before the
next command from run_rc_command(), as far as i can tell.


what i want to do is basically the same that is done by
rc.shutdown: going through rc.d/ in reverse order and calling every
script with a 'stop' argument. my code is almost the same as in
rc.shutdown. if i run test_stop manually (i.e. not through
run_rc_command "$1" at the bottom of my script), everything seems to
work just fine.

can someone help me with this?

thanks, t.
-------------- next part --------------
#!/bin/sh

# PROVIDE: test
# BEFORE: rcconf
# KEYWORD: FreeBSD

. /etc/rc.subr

name="test"
rcvar=`set_rcvar`
load_rc_config $name

start_cmd="test_start"
stop_cmd="test_stop"

test_start () {
  # do some stuff
}

test_stop () {

  files=` rcorder -k FreeBSD /etc/rc.d/* 2>/dev/null `

  _revlist=
  for _revfile in $files; do
    _revlist="$_revfile${script_name_sep}$_revlist"
  done

  for _rc_elem in $_revlist; do
    if [ "${_rc_elem}" = "/etc/rc.d/test" ] ; then
      break
    fi
    run_rc_script $_rc_elem stop
  done
}

run_rc_command "$1"


More information about the freebsd-current mailing list