Index: libexec/rc/rc.subr =================================================================== --- libexec/rc/rc.subr +++ libexec/rc/rc.subr @@ -983,7 +983,7 @@ _nice=\$${name}_nice _user=\$${name}_user \ _group=\$${name}_group _groups=\$${name}_groups \ _fib=\$${name}_fib _env=\$${name}_env \ - _prepend=\$${name}_prepend _login_class=\${${name}_login_class:-daemon} \ + _prepend=\$${name}_prepend _login_class=\${${name}_login_class-daemon} \ _limits=\$${name}_limits _oomprotect=\$${name}_oomprotect \ _env_file=\$${name}_env_file @@ -1140,8 +1140,15 @@ fi fi - # Prepend default limits - _doit="$_cd limits -C $_login_class $_limits $_doit" + # prepend default limits + # + if [ -n "$_login_class" ] || [ -n "$_limits" ]; then + _doit="limits ${_login_class:+-C $_login_class} $_limits $_doit" + fi + + # lastly, prepend the directory change + # + _doit="$_cd $_doit" # run the full command #