1
1
openmpi/opal/util/fd.h
Jeff Squyres 790cdb5cc7 Sigh. It helps when you commit the right version of the finished
code.

This commit fixes minor errors in the incorrectly-committed r31513
(new fd close-on-exec convenience function).

Refs trac:4550

This commit was SVN r31514.

The following SVN revision numbers were found above:
  r31513 --> open-mpi/ompi@e1655ae68d

The following Trac tickets were found above:
  Ticket 4550 --> https://svn.open-mpi.org/trac/ompi/ticket/4550
2014-04-24 13:20:32 +00:00

69 строки
1.7 KiB
C

/*
* Copyright (c) 2008-2014 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2009 Sandia National Laboratories. All rights reserved.
*
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/* @file */
#ifndef OPAL_UTIL_FD_H_
#define OPAL_UTIL_FD_H_
#include "opal_config.h"
BEGIN_C_DECLS
/**
* Read a complete buffer from a file descriptor.
*
* @param fd File descriptor
* @param len Number of bytes to read
* @param buffer Pre-allocated buffer (large enough to hold len bytes)
*
* @returns OPAL_SUCCESS upon success.
* @returns OPAL_ERR_TIMEOUT if the fd closes before reading the full amount.
* @returns OPAL_ERR_IN_ERRNO otherwise.
*
* Loop over reading from the fd until len bytes are read or an error
* occurs. EAGAIN and EINTR are transparently handled.
*/
OPAL_DECLSPEC int opal_fd_read(int fd, int len, void *buffer);
/**
* Write a complete buffer to a file descriptor.
*
* @param fd File descriptor
* @param len Number of bytes to write
* @param buffer Buffer to write from
*
* @returns OPAL_SUCCESS upon success.
* @returns OPAL_ERR_IN_ERRNO otherwise.
*
* Loop over writing to the fd until len bytes are written or an error
* occurs. EAGAIN and EINTR are transparently handled.
*/
OPAL_DECLSPEC int opal_fd_write(int fd, int len, const void *buffer);
/**
* Convenience function to set a file descriptor to be close-on-exec.
*
* @param fd File descriptor
*
* @returns OPAL_SUCCESS upon success (or if the system does not
* support close-on-exec behavior).
* @returns OPAL_ERR_IN_ERRNO otherwise.
*
* This is simply a convenience function because there's a few steps
* to setting a file descriptor to be close-on-exec.
*/
OPAL_DECLSPEC int opal_fd_set_cloexec(int fd);
END_C_DECLS
#endif