From 8e58c9596b3d348ca39544407adfe47cc8b8ba8c Mon Sep 17 00:00:00 2001 From: phx Date: Sat, 31 Oct 2015 12:31:37 +0000 Subject: [PATCH] PR misc/50046 Remove the expensive tests in _have_rc_postprocessor(), as proposed by apb@. It more than halves the multiuser boot time on slow machines and brings it back near to the previous level. --- etc/rc.subr | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/etc/rc.subr b/etc/rc.subr index d76c17509266..7cd724ff3227 100644 --- a/etc/rc.subr +++ b/etc/rc.subr @@ -1,4 +1,4 @@ -# $NetBSD: rc.subr,v 1.96 2014/10/07 19:09:45 roy Exp $ +# $NetBSD: rc.subr,v 1.97 2015/10/31 12:31:37 phx Exp $ # # Copyright (c) 1997-2011 The NetBSD Foundation, Inc. # All rights reserved. @@ -814,19 +814,9 @@ $command $rc_flags $command_args" _have_rc_postprocessor() { # Cheap tests that fd and pid are set, fd is writable. - [ -n "${_rc_postprocessor_fd}" ] || return 1 - [ -n "${_rc_pid}" ] || return 1 - eval ": >&${_rc_postprocessor_fd}" 2>/dev/null || return 1 - - # More expensive test that pid is running. - # Unset _rc_pid if this fails. - kill -0 "${_rc_pid}" 2>/dev/null \ - || { unset _rc_pid; return 1; } - - # More expensive test that pid appears to be - # a shell running an rc script. - # Unset _rc_pid if this fails. - expr "$(ps -p "${_rc_pid}" -o command=)" : ".*sh .*/rc.*" >/dev/null \ + [ -n "${_rc_pid}" ] || { unset _rc_pid; return 1; } + [ -n "${_rc_postprocessor_fd}" ] || { unset _rc_pid; return 1; } + eval ": >&${_rc_postprocessor_fd}" 2>/dev/null \ || { unset _rc_pid; return 1; } return 0