diff options
| author | Justin Bedo <cu@cua0.org> | 2018-09-27 21:13:50 +1000 | 
|---|---|---|
| committer | Justin Bedo <cu@cua0.org> | 2018-09-28 07:54:22 +1000 | 
| commit | 188b59fc60925a0f3d67feae76e4d7e48a0d0770 (patch) | |
| tree | 1a6e5431fb5d4cadc84399e8b2d2152bf98a8728 | |
| parent | 8df1eae273acaf97ead80b3f5ef78a387be0934b (diff) | |
Improve cleanup of qsub
| -rw-r--r-- | lib/qsub.nix | 9 | 
1 files changed, 8 insertions, 1 deletions
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      '';  | 
