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>
# 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 "$@"