Back to index

nagios-plugins  1.4.16
Defines | Functions
safe-read.c File Reference
#include <config.h>
#include "safe-read.h"
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include <limits.h>
#include "safe-write.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


#define IS_EINTR(x)   0
#define safe_rw   safe_read
#define rw   read
#define const   /* empty */


size_t safe_rw (int fd, void const *buf, size_t count)

Define Documentation

#define const   /* empty */

Definition at line 49 of file safe-read.c.

#define IS_EINTR (   x)    0

Definition at line 37 of file safe-read.c.

#define rw   read

Definition at line 47 of file safe-read.c.

#define safe_rw   safe_read

Definition at line 46 of file safe-read.c.

Function Documentation

size_t safe_rw ( int  fd,
void const buf,
size_t  count 

Definition at line 56 of file safe-read.c.

  /* Work around a bug in Tru64 5.1.  Attempting to read more than
     INT_MAX bytes fails with errno == EINVAL.  See
     When decreasing COUNT, keep it block-aligned.  */
  enum { BUGGY_READ_MAXIMUM = INT_MAX & ~8191 };

  for (;;)
      ssize_t result = rw (fd, buf, count);

      if (0 <= result)
        return result;
      else if (IS_EINTR (errno))
      else if (errno == EINVAL && BUGGY_READ_MAXIMUM < count)
        count = BUGGY_READ_MAXIMUM;
        return result;