Back to index

glibc  2.9
spawn_faction_addopen.c File Reference
#include <errno.h>
#include <spawn.h>
#include <unistd.h>
#include "spawn_int.h"

Go to the source code of this file.


int posix_spawn_file_actions_addopen (posix_spawn_file_actions_t *file_actions, int fd, const char *path, int oflag, mode_t mode)

Function Documentation

int posix_spawn_file_actions_addopen ( posix_spawn_file_actions_t file_actions,
int  fd,
const char *  path,
int  oflag,
mode_t  mode 

Definition at line 28 of file spawn_faction_addopen.c.

  int maxfd = __sysconf (_SC_OPEN_MAX);
  struct __spawn_action *rec;

  /* Test for the validity of the file descriptor.  */
  if (fd < 0 || fd >= maxfd)
    return EBADF;

  /* Allocate more memory if needed.  */
  if (file_actions->__used == file_actions->__allocated
      && __posix_spawn_file_actions_realloc (file_actions) != 0)
    /* This can only mean we ran out of memory.  */
    return ENOMEM;

  /* Add the new value.  */
  rec = &file_actions->__actions[file_actions->__used];
  rec->tag = spawn_do_open;
  rec->action.open_action.fd = fd;
  rec->action.open_action.path = path;
  rec->action.open_action.oflag = oflag;
  rec->action.open_action.mode = mode;

  /* Account for the new entry.  */

  return 0;

Here is the call graph for this function: