[Bug 267110] xargs return incorrect exit code when run in parallel mode

From: <bugzilla-noreply_at_freebsd.org>
Date: Sun, 16 Oct 2022 05:07:41 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=267110

            Bug ID: 267110
           Summary: xargs return incorrect exit code when run in parallel
                    mode
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: misc
          Assignee: bugs@FreeBSD.org
          Reporter: duliujimmy@hotmail.com

when xargs runs in parallel mode (using -P flag), it may sometimes return
incorrect exit code. 

The following code shows current (incorrect) behaviour: /bin directory exists,
/foo directory does not exist. `echo /bin /foo | xargs -n1 -P2 test -d`
sometimes return 0 sometimes return 1:

```
root@freebsd:~ # test -d /bin
root@freebsd:~ # echo $?
0
root@freebsd:~ # test -d /foo
root@freebsd:~ # echo $?
1
root@freebsd:~ # echo /bin /foo | xargs -n1 -P2 test -d
root@freebsd:~ # echo $?
0
root@freebsd:~ # echo /bin /foo | xargs -n1 -P2 test -d
root@freebsd:~ # echo $?
1
root@freebsd:~ # echo /bin /foo | xargs -n1 -P2 test -d
root@freebsd:~ # echo $?
0
```

-- 
You are receiving this mail because:
You are the assignee for the bug.