[PATCH] libio: Avoid dup already opened file descriptor [BZ#21393]

Siddhesh Poyarekar siddhesh@gotplt.org
Mon May 22 20:04:00 GMT 2017


On Monday 22 May 2017 10:55 PM, Adhemerval Zanella wrote:
>  If the operation fails, a null pointer is returned; otherwise,
> -@code{freopen} returns @var{stream}.
> +@code{freopen} returns @var{stream}.  Also for Linux, due internal dup3
> +usage, it might fail with errno set to EBUSY during a race condition
> +with @code{open} and @code{dup}.

On Linux, @code{freopen} may fail and set @code{errno} to @{EBUSY} when
the kernel structure for the old file descriptor was not initialized
completely before @code{freopen} was called.

OK with that change.

Siddhesh



More information about the Libc-alpha mailing list