aboutgitcodelistschat:MatrixIRC
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2023-06-03 08:29:30 +0200
committerStefano Brivio <sbrivio@redhat.com>2023-06-03 08:30:51 +0200
commit6a8f05f9f0d10b257edce878381bf22b1249537e (patch)
tree855bb0e91472affbec67681d4327f806c1d37a14
parentd5e4e57926308e72bbfdda19ba148654fd3eac62 (diff)
downloadseitan-6a8f05f9f0d10b257edce878381bf22b1249537e.tar
seitan-6a8f05f9f0d10b257edce878381bf22b1249537e.tar.gz
seitan-6a8f05f9f0d10b257edce878381bf22b1249537e.tar.bz2
seitan-6a8f05f9f0d10b257edce878381bf22b1249537e.tar.lz
seitan-6a8f05f9f0d10b257edce878381bf22b1249537e.tar.xz
seitan-6a8f05f9f0d10b257edce878381bf22b1249537e.tar.zst
seitan-6a8f05f9f0d10b257edce878381bf22b1249537e.zip
seitan-run: Assorted cleanups
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rwxr-xr-xseitan-run32
1 files changed, 18 insertions, 14 deletions
diff --git a/seitan-run b/seitan-run
index 76986e1..5c0e18f 100755
--- a/seitan-run
+++ b/seitan-run
@@ -1,7 +1,7 @@
+#!/bin/sh -ex
+#
# SPDX-License-Identifier: AGPL-3.0-or-later
#
-#!/bin/sh -ex
-#
# seitan - Syscall Expressive Interpreter, Transformer and Notifier
#
# seitan-run - Convenience script: run target command with syscall model
@@ -15,23 +15,27 @@ usage() {
exit 1
}
-[ ${#} -lt 2 ] && usage
+cleanup() {
+ rm -rf "${DIR}"
+}
-[ -z "${DIR}" ] && DIR="$(mktemp -d)"
+trap cleanup EXIT INT
-[ -z "${COOKER}" ] && COOKER="$(command -v ./seitan-cooker seitan-cooker)"
-[ -z "${COOKER}" ] && echo "seitan-cooker not found" && exit 1
+[ ${#} -lt 2 ] && usage
-[ -z "${EATER}" ] && EATER="$(command -v ./seitan-eater seitan-eater)"
-[ -z "${EATER}" ] && echo "seitan-eater not found" && exit 1
+[ -z "${DIR}" ] && DIR="$(mktemp -d)"
-[ -z "${SEITAN}" ] && SEITAN="$(command -v ./seitan seitan)"
-[ -z "${SEITAN}" ] && echo "seitan not found" && exit 1
+[ -z "${COOKER}" ] && COOKER="$(command -v ./seitan-cooker seitan-cooker)"
+[ -z "${COOKER}" ] && echo "seitan-cooker not found" && exit 1
+
+[ -z "${EATER}" ] && EATER="$(command -v ./seitan-eater seitan-eater)"
+[ -z "${EATER}" ] && echo "seitan-eater not found" && exit 1
+
+[ -z "${SEITAN}" ] && SEITAN="$(command -v ./seitan seitan)"
+[ -z "${SEITAN}" ] && echo "seitan not found" && exit 1
"${COOKER}" "${1}" "${DIR}/gluten" "${DIR}/bpf"
shift
( "${EATER}" -i "${DIR}/bpf" -- ${@} & echo "${!}" > "${DIR}/eater.pid" 2>&1 ) &
-sleep 1
-"${SEITAN}" -p "$(cat ${DIR}/eater.pid)" -i "${DIR}/gluten"
-
-rm -rf "${DIR}"
+sleep 0.1 || sleep 1
+"${SEITAN}" -p "$(cat "${DIR}/eater.pid")" -i "${DIR}/gluten"