From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Tremer To: development@lists.ipfire.org Subject: Re: [RFC PATCH] initscripts: Add switch to start processes in background Date: Wed, 04 Aug 2021 16:34:59 +0200 Message-ID: <0049E8E1-CF52-4A7B-98FE-53ECE72E2ECB@ipfire.org> In-Reply-To: <5811d6b8-80c2-6ae5-5ac6-bc73e566e07f@posteo.de> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============3946946491370655677==" List-Id: --===============3946946491370655677== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Cool. Thanks for the feedback. @Arne: Please merge this patch. -Michael > On 28 Jul 2021, at 19:31, Holger Sunke wrote: >=20 > This works for me, thank you. >=20 > Am 27.07.21 um 10:59 schrieb Michael Tremer: >> Since systemd, many programs no longer behave like a well-behaved >> daemon. To avoid any extra solutions, this patch adds a -b switch which >> will start a program in the background and throw away any output. >> The behaviour remains unchanged for any other programs. >> Signed-off-by: Michael Tremer >> --- >> src/initscripts/system/functions | 17 +++++++++++++++-- >> 1 file changed, 15 insertions(+), 2 deletions(-) >> diff --git a/src/initscripts/system/functions b/src/initscripts/system/fun= ctions >> index d610a524d..e44a2b4a1 100644 >> --- a/src/initscripts/system/functions >> +++ b/src/initscripts/system/functions >> @@ -436,6 +436,7 @@ getpids() >> #************************************************************************= ******* >> loadproc() >> { >> + local background=3D"" >> local pidfile=3D"" >> local forcestart=3D"" >> local nicelevel=3D"" >> @@ -448,6 +449,10 @@ loadproc() >> while true >> do >> case "${1}" in >> + -b) >> + background=3D"1" >> + shift 1 >> + ;; >> -f) >> forcestart=3D"1" >> shift 1 >> @@ -506,8 +511,16 @@ loadproc() >> cmd=3D"nice -n "${nicelevel}" ${cmd}" >> fi >> - ${cmd} >> - evaluate_retval # This is "Probably" not LSB compliant, but required to = be compatible with older bootscripts >> + if [ -n "${background}" ]; then >> + ( >> + ${cmd} &>/dev/null >> + ) & >> + evaluate_retval >> + else >> + ${cmd} >> + evaluate_retval # This is "Probably" not LSB compliant, but required to= be compatible with older bootscripts >> + fi >> + >> return 0 >> } >> =20 --===============3946946491370655677==--