Blame gnulib/lib/safe-write.h

Packit Service 51e54d
/* An interface to write() that retries after interrupts.
Packit Service 51e54d
   Copyright (C) 2002, 2009-2014 Free Software Foundation, Inc.
Packit Service 51e54d
Packit Service 51e54d
   This program is free software: you can redistribute it and/or modify
Packit Service 51e54d
   it under the terms of the GNU General Public License as published by
Packit Service 51e54d
   the Free Software Foundation; either version 3 of the License, or
Packit Service 51e54d
   (at your option) any later version.
Packit Service 51e54d
Packit Service 51e54d
   This program is distributed in the hope that it will be useful,
Packit Service 51e54d
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 51e54d
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service 51e54d
   GNU General Public License for more details.
Packit Service 51e54d
Packit Service 51e54d
   You should have received a copy of the GNU General Public License
Packit Service 51e54d
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
Packit Service 51e54d
Packit Service 51e54d
/* Some system calls may be interrupted and fail with errno = EINTR in the
Packit Service 51e54d
   following situations:
Packit Service 51e54d
     - The process is stopped and restarted (signal SIGSTOP and SIGCONT, user
Packit Service 51e54d
       types Ctrl-Z) on some platforms: Mac OS X.
Packit Service 51e54d
     - The process receives a signal for which a signal handler was installed
Packit Service 51e54d
       with sigaction() with an sa_flags field that does not contain
Packit Service 51e54d
       SA_RESTART.
Packit Service 51e54d
     - The process receives a signal for which a signal handler was installed
Packit Service 51e54d
       with signal() and for which no call to siginterrupt(sig,0) was done,
Packit Service 51e54d
       on some platforms: AIX, HP-UX, IRIX, OSF/1, Solaris.
Packit Service 51e54d
Packit Service 51e54d
   This module provides a wrapper around write() that handles EINTR.  */
Packit Service 51e54d
Packit Service 51e54d
#include <stddef.h>
Packit Service 51e54d
Packit Service 51e54d
#define SAFE_WRITE_ERROR ((size_t) -1)
Packit Service 51e54d
Packit Service 51e54d
/* Write up to COUNT bytes at BUF to descriptor FD, retrying if interrupted.
Packit Service 51e54d
   Return the actual number of bytes written, zero for EOF, or SAFE_WRITE_ERROR
Packit Service 51e54d
   upon error.  */
Packit Service 51e54d
extern size_t safe_write (int fd, const void *buf, size_t count);