Back to index

nagios-plugins  1.4.16
Functions
pipe-safer.c File Reference
#include <config.h>
#include "unistd-safer.h"
#include <unistd.h>
#include <errno.h>

Go to the source code of this file.

Functions

int pipe_safer (int fd[2])

Function Documentation

int pipe_safer ( int  fd[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: