From patchwork Tue Jul 27 08:59:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tremer X-Patchwork-Id: 4563 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4GYrM10cG4z3xGr for ; Tue, 27 Jul 2021 08:59:09 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4GYrLz6HvLz6YM; Tue, 27 Jul 2021 08:59:07 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4GYrLz3ysyz2xlJ; Tue, 27 Jul 2021 08:59:07 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4GYrLx4hsjz2x9h for ; Tue, 27 Jul 2021 08:59:05 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4GYrLx0xNlzHt; Tue, 27 Jul 2021 08:59:05 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1627376345; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=bf1qBERHEtrU7m5cVtkHr6lCGI1MpitDcgXputMPq1s=; b=TyhJVxkuqAMYEuDBtc9ixw64dslefiv4CTht0PpG7OBjtbYSPx//+AW/bT4N9+nYp8wAJ/ vJZH1ujgFMqQiIDg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1627376345; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=bf1qBERHEtrU7m5cVtkHr6lCGI1MpitDcgXputMPq1s=; b=mAMRgezfR7pBeafMPWB7vefypg5oun4frqMs42tNzD1T0mQg6tq7nPplGmOukDc+Gssy2A MCWYvYyrNome/vhSdjN7zQ7ScAe33SyVOaMLh5JSqIrSbF5xL5s0HYAya72J6ZNEAKofNV +8JlMSsyytD80nT1Hblm3bx3VWfzFOVfITRIVK1cLA3xQvjo5FQKjq+bT921TJ8CiXIxNg 57IpdmmGK7cRJaCxqbRNH7xLbDmXMCVCQYenfsQlpX7To5k3vjAvJ6TT2AAJJQbviX9lbH oSOamCTHQYIuvf+qZDzB4qkfPiP5bEHVeDExRspV+kaggTYmvN2l+bBoc38BZA== From: Michael Tremer To: development@lists.ipfire.org Subject: [RFC PATCH] initscripts: Add switch to start processes in background Date: Tue, 27 Jul 2021 08:59:00 +0000 Message-Id: <20210727085900.2253-1-michael.tremer@ipfire.org> MIME-Version: 1.0 X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Tremer Errors-To: development-bounces@lists.ipfire.org Sender: "Development" 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/functions index d610a524d..e44a2b4a1 100644 --- a/src/initscripts/system/functions +++ b/src/initscripts/system/functions @@ -436,6 +436,7 @@ getpids() #******************************************************************************* loadproc() { + local background="" local pidfile="" local forcestart="" local nicelevel="" @@ -448,6 +449,10 @@ loadproc() while true do case "${1}" in + -b) + background="1" + shift 1 + ;; -f) forcestart="1" shift 1 @@ -506,8 +511,16 @@ loadproc() cmd="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 }