From 188b59fc60925a0f3d67feae76e4d7e48a0d0770 Mon Sep 17 00:00:00 2001 From: Justin Bedo Date: Thu, 27 Sep 2018 21:13:50 +1000 Subject: Improve cleanup of qsub --- lib/qsub.nix | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/qsub.nix b/lib/qsub.nix index 7c02144..528773e 100644 --- a/lib/qsub.nix +++ b/lib/qsub.nix @@ -26,6 +26,14 @@ SHELL=/bin/sh NIX_BUILD_CORES=${toString ppn} id=$(qsub -l nodes=1:ppn=${toString ppn},mem=${toString mem}gb,walltime=${walltime} ${script}) + + function cleanup { + qstat ''${id%%.} 2> /dev/null > /dev/null && qdel $id || true + sleep 5 + rm -rf ${tmpDir}/$id + } + trap cleanup INT TERM EXIT + cp -r $TMPDIR ${tmpDir}/$id set > ${tmpDir}/$id/nix-set while qstat ''${id%%.} 2> /dev/null > /dev/null ; do @@ -34,7 +42,6 @@ cat ${tmpDir}/$id/qsub-stderr >&2 cat ${tmpDir}/$id/qsub-stdout exitCode=$(cat ${tmpDir}/$id/qsub-exit) - rm -rf ${tmpDir}/$id exit $exitCode ''; -- cgit v1.2.3