Skip to content

Commit 2f88c97

Browse files
authored
[mpiexecjl] Return exit code of the mpiexec process (#834)
1 parent d2c81c0 commit 2f88c97

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

bin/mpiexecjl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,12 @@ fi
6161
SCRIPT='
6262
using MPI
6363
ENV["JULIA_PROJECT"] = dirname(Base.active_project())
64-
mpiexec(exe -> run(`$exe $ARGS`))
64+
proc = run(pipeline(`$(mpiexec()) $(ARGS)`; stdout, stderr); wait=false)
65+
wait(proc)
66+
if !iszero(proc.exitcode)
67+
@error "The MPI process failed" proc
68+
end
69+
exit(proc.exitcode)
6570
'
6671

6772
if [ -n "${PROJECT_ARG}" ]; then

test/mpiexecjl.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,10 @@ using MPI
3434
# Without arguments, or only with the `--project` option, the wrapper will fail
3535
@test !withenv(() -> success(`$(mpiexecjl) --project=$(dir)`), env...)
3636
@test !withenv(() -> success(`$(mpiexecjl)`), env...)
37+
# Test that the wrapper exits with the same exit code as the MPI process
38+
exit_code = 10
39+
p = run(`$(mpiexecjl) -n $(nprocs) --project=$(dir) $(julia) --startup-file=no -e "exit($(exit_code))"`; wait=false)
40+
wait(p)
41+
@test p.exitcode == exit_code
3742
end
3843
end

0 commit comments

Comments
 (0)