PrimeIntellect/SWE-rebench-V2 huggingface dataset:
Repository: JuliaParallel/MPI.jl (julia)

Issue:
Cannot return user specified exit status with `exit()` when using `mpiexecjl`
If the command
```
mpiexecjl -n 2 julia -e "using MPI; MPI.Init(); exit(100)"
```
is run, the reported exit status returned by
```
echo $?
```
will always return `1` regardless of the argument of `exit()`.

Pull request:
Should fix #833.  I don't have the time to write tests now though, so opening as draft.  @cohensbw could you please test this?  With this PR I get
```console
% mpiexecjl -np 2 --project julia --color=yes -e 'exit(2)'; echo $?
2
```

Patch:
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


Test patch:
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