[PATCH v2] stdio-common: In tst-setvbuf2, close helper thread descriptor only if opened
Joseph Myers
josmyers@redhat.com
Mon Apr 7 20:12:55 GMT 2025
On Mon, 7 Apr 2025, Florian Weimer wrote:
> The helper thread may get canceled before the open system
> call succeds. Then ThreadData.fd remains zero, and eventually
> the xclose call in end_reader_thread fails because descriptor 0
> is not open.
>
> Instead, initialize the fd member to -1 (not a valid descriptor)
> and close the descriptor only if valid. Do this in a new end_thread
> helper routine.
>
> Also add more error checking to close operations.
>
> Fixes commit 95b780c1d0549678c0a244c6e2112ec97edf0839 ("stdio: Add
> more setvbuf tests").
>
> ---
> v2: Correct commit subject. I had an earlier fix which used a
> cancellation handler, but this approach is simpler.
OK.
--
Joseph S. Myers
josmyers@redhat.com
More information about the Libc-alpha
mailing list