]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
make.sh: Create a better PID 1 inside the environment
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 28 Oct 2025 17:13:44 +0000 (17:13 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 29 Oct 2025 11:05:06 +0000 (11:05 +0000)
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 <michael.tremer@ipfire.org>
tools/execute.sh

index b3bf42f223d392234e01527309491566497b45d4..f77cea2bd135f354fc49681191ca4d3f9defc07e 100755 (executable)
 # 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 "$@"