We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b62854c commit db91d6aCopy full SHA for db91d6a
.github/scripts/monitor_slurm_job.sh
@@ -2,7 +2,15 @@
2
# Monitor a SLURM job and stream its output in real-time
3
# Usage: monitor_slurm_job.sh <job_id> <output_file>
4
5
-set -e
+set -euo pipefail
6
+
7
+# Cleanup handler to prevent orphaned tail processes
8
+cleanup() {
9
+ if [ -n "${tail_pid:-}" ]; then
10
+ kill "${tail_pid}" 2>/dev/null || true
11
+ fi
12
+}
13
+trap cleanup EXIT
14
15
if [ $# -ne 2 ]; then
16
echo "Usage: $0 <job_id> <output_file>"
@@ -96,8 +104,8 @@ if [ -f "$output_file" ]; then
96
104
done
97
105
fi
98
106
99
-# Stop tailing
100
-kill $tail_pid 2>/dev/null || true
107
+# Stop tailing (trap will also handle this on exit)
108
+kill "${tail_pid}" 2>/dev/null || true
101
109
102
110
echo ""
103
111
echo "=== Final output ==="
0 commit comments