From: Michael Tremer Date: Tue, 28 Oct 2025 17:13:44 +0000 (+0000) Subject: make.sh: Create a better PID 1 inside the environment X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5a20173cbb11edad06f7bc4e36deda4d27f6c6dc;p=ipfire-2.x.git make.sh: Create a better PID 1 inside the environment This is required so that we won't have any make processes locking up any more. When the build process is getting aborted, this script will now cleanly terminate anything inside the container and not block make as PID 1. Signed-off-by: Michael Tremer --- diff --git a/tools/execute.sh b/tools/execute.sh index b3bf42f22..f77cea2bd 100755 --- a/tools/execute.sh +++ b/tools/execute.sh @@ -22,8 +22,22 @@ # This is a helper script that is called after we have created the new # namespaces to perform further setup. This will be executed on the host. -# Bring up the loopback interface -ip link set lo up &>/dev/null +set -euo pipefail -# Execute the given command -exec "$@" +main() { + local r=0 + + # Bring up the loopback interface + ip link set lo up &>/dev/null + + # Trap SIGINT & SIGTERM but actually don't do anything + trap "" SIGINT SIGTERM + + # Execute the given command and save the return code + "$@" || r="${?}" + + # Terminate with the code from the command + exit "${r}" +} + +main "$@"