Back to index

nagios-plugins  1.4.16
Functions
unistd-safer.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int dup_safer (int)
int fd_safer (int)
int pipe_safer (int[2])

Function Documentation

int dup_safer ( int  )

Definition at line 31 of file dup-safer.c.

{
  return fcntl (fd, F_DUPFD, STDERR_FILENO + 1);
}

Here is the caller graph for this function:

int fd_safer ( int  )

Definition at line 37 of file fd-safer.c.

{
  if (STDIN_FILENO <= fd && fd <= STDERR_FILENO)
    {
      int f = dup_safer (fd);
      int e = errno;
      close (fd);
      errno = e;
      fd = f;
    }

  return fd;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int pipe_safer ( int  [2])

Definition at line 31 of file pipe-safer.c.

{
#if HAVE_PIPE
  if (pipe (fd) == 0)
    {
      int i;
      for (i = 0; i < 2; i++)
        {
          fd[i] = fd_safer (fd[i]);
          if (fd[i] < 0)
            {
              int e = errno;
              close (fd[1 - i]);
              errno = e;
              return -1;
            }
        }

      return 0;
    }
#else
  errno = ENOSYS;
#endif

  return -1;
}

Here is the call graph for this function: