This is the mail archive of the
mailing list for the glibc project.
Re: [RFC][BZ #14627] Make linux close errno to EINPROGRESS when interrupted in signal.
- From: Adhemerval Zanella <azanella at linux dot vnet dot ibm dot com>
- To: libc-alpha at sourceware dot org
- Date: Thu, 05 Dec 2013 15:24:05 -0200
- Subject: Re: [RFC][BZ #14627] Make linux close errno to EINPROGRESS when interrupted in signal.
- Authentication-results: sourceware.org; auth=none
- References: <20131205171054 dot GA14905 at domone dot podge>
I wonder if it would break applications that relies on the Linux behavior.
On 05-12-2013 15:10, OndÅej BÃlka wrote:
> As was recently said
> linux when close is interrupted by signal closes file descriptor but
> returns EINTR errno which lies application about restartability. As
> kernel does not restart close on SA_RESTART only thing needed is to
> return EINPROGRESS instead EINTR as specified by POSIX.
> I do not have actual implementation ready as close is automatically
> generated syscall wrapper.
> Second concern is cancelability, there is a close_nocancel macro and
> also in libc.so close is implemented as header before close_nocancel but
> i couldn't find definition.
> Could somebody clarify?
> As actual implementation one could use something like this. As in fclose
> we use noncancelable version should we also disable cancelability in
> diff --git a/sysdeps/unix/sysv/linux/close.c b/sysdeps/unix/sysv/linux/close.c
> new file mode 100644
> index 0000000..223d6ed
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/close.c
> @@ -0,0 +1,44 @@
> +/* Copyright (C) 2013 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <http://www.gnu.org/licenses/>. */
> +#include <errno.h>
> +#include <fcntl.h>
> +#include <stdio.h>
> +#include <sysdep-cancel.h>
> +__libc_close (int fd)
> + if (SINGLE_THREAD_P)
> + return INLINE_SYSCALL (close, 1, fd);
> + int oldtype = LIBC_CANCEL_ASYNC ();
> + int result = INLINE_SYSCALL (close, 1, fd);
> + if (errno == EINTR)
> + errno = EINPROGRESS;
> + LIBC_CANCEL_RESET (oldtype);
> + return result;
> +weak_alias (__libc_close, __close)
> +libc_hidden_weak (__close)
> +weak_alias (__libc_close, close)