diff --git a/bin/mpiexecjl b/bin/mpiexecjl index 83c7f8801..137c9b461 100755 --- a/bin/mpiexecjl +++ b/bin/mpiexecjl @@ -61,7 +61,12 @@ fi SCRIPT=' using MPI ENV["JULIA_PROJECT"] = dirname(Base.active_project()) -mpiexec(exe -> run(`$exe $ARGS`)) +proc = run(pipeline(`$(mpiexec()) $(ARGS)`; stdout, stderr); wait=false) +wait(proc) +if !iszero(proc.exitcode) + @error "The MPI process failed" proc +end +exit(proc.exitcode) ' if [ -n "${PROJECT_ARG}" ]; then diff --git a/test/mpiexecjl.jl b/test/mpiexecjl.jl index 388e58a89..4d40bef18 100644 --- a/test/mpiexecjl.jl +++ b/test/mpiexecjl.jl @@ -34,5 +34,10 @@ using MPI # Without arguments, or only with the `--project` option, the wrapper will fail @test !withenv(() -> success(`$(mpiexecjl) --project=$(dir)`), env...) @test !withenv(() -> success(`$(mpiexecjl)`), env...) + # Test that the wrapper exits with the same exit code as the MPI process + exit_code = 10 + p = run(`$(mpiexecjl) -n $(nprocs) --project=$(dir) $(julia) --startup-file=no -e "exit($(exit_code))"`; wait=false) + wait(p) + @test p.exitcode == exit_code end end