control: add trap for bad exit
This commit is contained in:
parent
fb0dee4b61
commit
7c94997023
@ -18,9 +18,25 @@ stdenv.mkDerivation {
|
|||||||
installPhase = ''
|
installPhase = ''
|
||||||
cat > $out <<"EOF"
|
cat > $out <<"EOF"
|
||||||
#!/bin/sh -e
|
#!/bin/sh -e
|
||||||
for n in $(seq 1 ${toString loops}); do
|
|
||||||
|
function badexit() {
|
||||||
|
errcode=$?
|
||||||
|
if [ $errcode != 0 ]; then
|
||||||
|
printf "exit %d\n" $errcode > "$basedir/status"
|
||||||
|
echo "exiting with $errcode"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo 1 > "$basedir/done"
|
||||||
|
exit $errcode
|
||||||
|
}
|
||||||
|
|
||||||
|
trap badexit EXIT
|
||||||
|
|
||||||
|
basedir=$(pwd)
|
||||||
|
loops=${toString loops}
|
||||||
|
for n in $(seq 1 $loops); do
|
||||||
export GARLIC_RUN="$n"
|
export GARLIC_RUN="$n"
|
||||||
echo "running $n of ${toString loops}" > status
|
echo "run $n/$loops" > status
|
||||||
mkdir "$n"
|
mkdir "$n"
|
||||||
cd "$n"
|
cd "$n"
|
||||||
mkdir .garlic
|
mkdir .garlic
|
||||||
@ -29,7 +45,7 @@ stdenv.mkDerivation {
|
|||||||
date +%s > .garlic/total_time_end
|
date +%s > .garlic/total_time_end
|
||||||
cd ..
|
cd ..
|
||||||
done
|
done
|
||||||
echo "completed" > status
|
echo "ok" > status
|
||||||
EOF
|
EOF
|
||||||
chmod +x $out
|
chmod +x $out
|
||||||
'';
|
'';
|
||||||
|
Loading…
Reference in New Issue
Block a user