[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #38356] xargs -P option creates wrong result
From: |
Bernhard Voelker |
Subject: |
[bug #38356] xargs -P option creates wrong result |
Date: |
Thu, 21 Feb 2013 14:49:51 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2 |
Follow-up Comment #2, bug #38356 (project findutils):
The problem is that all parallel instances of grep have the
output file open for writing at the same time, and they do
not care about locking it. Therefore, I do not consider this
an xargs bug as xargs can nothing do about it.
Instead, you could synchronize writing of grep's output by an
intermediate wrapper script which obtains an exclusive lock on
stdout before writing the result:
#!/bin/sh
matches=$( grep "$@" )
flock 1
printf "%sn" "$matches"
Please note that you could also flock stdout before grep to
avoid the intermediate 'matches' variable, but this would
obvisouly lock out all other parallel grep processes until
this one has finished.
For larger program output, you may need to use a temporary
file instead of 'matches'.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?38356>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [bug #38356] xargs -P option creates wrong result, Frank Huang, 2013/02/20
- [bug #38356] xargs -P option creates wrong result, Congshi Huang, 2013/02/20
- [bug #38356] xargs -P option creates wrong result,
Bernhard Voelker <=
- [bug #38356] xargs -P option creates wrong result, Ole Tange, 2013/02/21
- [bug #38356] xargs -P option creates wrong result, Congshi Huang, 2013/02/23
- [bug #38356] xargs -P option creates wrong result, Dmitry V. Levin, 2013/02/23
- [bug #38356] xargs -P option creates wrong result, Bernhard Voelker, 2013/02/23
- [bug #38356] xargs -P option creates wrong result, Bernhard Voelker, 2013/02/23