On Tue, Nov 09, 2021 at 09:45:23AM +0100, Marcus MERIGHI wrote: > >Synopsis: shell script started by rcctl stops immediately > >Category: user > >Environment: > System : OpenBSD 7.0 > Details : OpenBSD 7.0-current (GENERIC.MP) #80: Mon Nov 8 08:34:04 > MST 2021 > > dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP > > Architecture: OpenBSD.amd64 > Machine : amd64 > >Description: > The following worked until one or two days ago: > The rc.d script: > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
rc.d(8) must be ksh(1) scripts, but you're omitting the interpreter, so sh(1) is assumed. > daemon="/usr/local/bin/mixsvr.sh" > daemon_timeout=5 > > . /etc/rc.d/rc.subr It is important because it influences code pulled in through the above line is interpreted. > rc_bg=YES > > rc_check() { > pgrep -f '/bin/sh -eu /usr/local/bin/mixsvr.sh' > } > > rc_stop() { > pkill -f '/bin/sh -eu /usr/local/bin/mixsvr.sh' > } > > rc_cmd $1 > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > /usr/local/bin/mixsvr.sh: > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > #!/bin/sh -eu > exec <&- > exec 2>&1 > > _nc= > > function _cleanup { > kill "${_nc}" 2>/dev/null > return > } > > trap "_cleanup ${_nc}" INT QUIT ABRT KILL ALRM TERM > > nc -n -k -l 10.23.4.5 2122 |& > _nc=${!} > exec 3<&p 4>&p > > while read -u3 _l; do > mixerctl -q ${_l} > done > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > output of "doas /etc/rc.d/mixsvr -d start": > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > $ doas /etc/rc.d/mixsvr start > mixsvr(ok) > $ ps auxwww | grep mix > <nothing, apart from the grep process> > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > output of "doas /etc/rc.d/mixsvr -d start": > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > $ doas /etc/rc.d/mixsvr -d start > doing _rc_parse_conf > doing _rc_quirks > mixsvr_flags empty, using default >< > doing rc_check > mixsvr > doing rc_start > doing _rc_wait start > /etc/rc.d/mixsvr: cannot open daemon_timeout: No such file or > directory This is from etc/rc.d/rc.subr revision 1.141 date: 2021/11/07 08:26:12; author: ajacoutot; state: Exp; lines: +4 -7; Use built-in SECONDS instead of hand roller timer. with a tweak from kn@ ok sthen@ where aja did - while [ $_i -lt ${daemon_timeout} ]; do + while (( SECONDS < daemon_timeout )); do which ksh(1) treats as arithmetic expression while sh(1) understands it as redirection (sh has no `(( ... ))' syntax). We should probably document that ksh is wanted. I'd say you were lucky to get away with sh(1) so far. All rc.d(8) scripts use ksh since the commit below and the rest of our scripts in base do so as well date: 2018/01/11 19:52:12; author: rpe; state: Exp; lines: +2 -2; Change the shebang line from /bin/sh to /bin/ksh in all base rc.d daemon scripts. discussed with and OK aja@ OK tb > Alarm clock > doing _rc_write_runfile > (ok) > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > I suspect that one of the recent rc.subr commits relates: > 2021-11-08 > https://marc.info/?l=openbsd-cvs&m=163635513510217 > 2021-11-07 > https://marc.info/?l=openbsd-cvs&m=163627390315386 > https://marc.info/?l=openbsd-cvs&m=163627358515272 > 2021-11-06 > https://marc.info/?l=openbsd-cvs&m=163620560525729 > https://marc.info/?l=openbsd-cvs&m=163619658623010 > https://marc.info/?l=openbsd-cvs&m=163619509722404 > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > Since wrapping it in tmux(1) works around the problem, I > suspect something with stdin/stdout/stderr redirection. > >How-To-Repeat: > $ doas /etc/rc.d/mixsvr -d start > $ ps auxwww | grep mixsvr > <nothing, apart from the grep process> > >Fix: > tmux new-session -d '/usr/local/bin/mixsvr.sh' >