On Tuesday, March 7, 2023 8:01:59 PM CET Pádraig Brady wrote: > On 07/03/2023 14:39, Kamil Dudka wrote: > > On Tuesday, March 7, 2023 2:28:05 AM CET Pádraig Brady wrote: > >> On 25/07/2019 11:59, Kamil Dudka wrote: > >>> I see two major issues with the patch: > >>> > >>> 1. If the file descriptor operates in non-blocking mode and it starts > >>> to return EAGAIN, tee will busy-loop (consume 100% CPU) until the file > >>> descriptor becomes ready again. > >>> > >>> 2. If fwrite() fails with EAGAIN, you cannot repeat the call with the same > >>> arguments because something might have been already written before EAGAIN > >>> was > >>> returned from a syscall. In that case, you would try to write the already > >>> written data repeatedly, which is not desired. > >>> > >>> A few months ago I proposed a patch that was free of the above issues but > >>> it > >>> addressed EAGAIN on tee's output only: > >>> > >>> https://lists.gnu.org/archive/html/coreutils/2018-09/msg00010.html > >>> > >>> The bad news is that the patch was rejected because a workaround exists. > >> > >> Given there are now two programs that trigger the issue, > >> and we've recently added portable poll() usage in the tee implementation, > >> I'm more inclined to add support for this now. > >> > >> The attached does this using our new iopoll module. > > > > The proposed patch works for me. Thank you for working on it! > > Thanks for the review. > Updated patch attached with a test. > > cheers, > Pádraig
Great idea with the test! I confirm it works in my environment. Kamil
