1.\" $OpenBSD: posix_spawn_file_actions_addopen.3,v 1.5 2012/04/11 14:32:38 jmc Exp $ 2.\" 3.\" Copyright (c) 2012 Marc Espie <espie@openbsd.org> 4.\" 5.\" Permission to use, copy, modify, and distribute this software for any 6.\" purpose with or without fee is hereby granted, provided that the above 7.\" copyright notice and this permission notice appear in all copies. 8.\" 9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16.\" 17.Dd $Mdocdate: April 11 2012 $ 18.Dt POSIX_SPAWN_FILE_ACTIONS_ADDOPEN 3 19.Os 20.Sh NAME 21.Nm posix_spawn_file_actions_addclose , 22.Nm posix_spawn_file_actions_adddup2 , 23.Nm posix_spawn_file_actions_addopen 24.Nd add action to close, dup2 or open file descriptor to file actions object 25.Sh SYNOPSIS 26.In spawn.h 27.Ft int 28.Fn posix_spawn_file_actions_addclose "posix_spawn_file_actions_t *file_actions" "int fildes" 29.Ft int 30.Fn posix_spawn_file_actions_adddup2 "posix_spawn_file_actions_t *file_actions" "int fildes" "int newfildes" 31.Ft int 32.Fn posix_spawn_file_actions_addopen "posix_spawn_file_actions_t *file_actions" "int fildes" "const char *restrict path" "int oflag" "mode_t mode" 33.Sh DESCRIPTION 34These function add an action to 35.Xr close 2 , 36.Xr dup2 2 , 37or 38.Xr open 2 39a file descriptor 40to a 41.Xr posix_spawn 3 42file actions object. 43.Pp 44Actions are executed in order in the child process: 45.Bl -dash 46.It 47The 48.Fn posix_spawn_file_actions_addclose 49function adds an action that causes 50.Bd -literal -offset indent 51close(fildes); 52.Ed 53.Pp 54to be called. 55.It 56The 57.Fn posix_spawn_file_actions_adddup2 58function adds an action that causes 59.Bd -literal -offset indent 60dup2(fildes, newfildes); 61.Ed 62.Pp 63to be called. 64.It 65The 66.Fn posix_spawn_file_actions_addopen 67adds an action that causes 68.Bd -literal -offset indent 69open(path, oflag, mode); 70.Ed 71.Pp 72to be called and the result to be forced as 73.Fa fildes 74(if 75.Fa fildes 76was already open before this action, the old file descriptor 77is closed before the action is performed). 78.Pp 79Note that 80.Fn posix_spawn_file_actions_addopen 81makes a copy of the 82.Fa path 83argument. 84.El 85.Sh RETURN VALUES 86Upon successful completion, these functions return zero. 87Otherwise they may return 88.Er EINVAL 89for negative file descriptors, or 90.Er ENOMEM 91if they run out of memory. 92.Sh SEE ALSO 93.Xr posix_spawn 3 , 94.Xr posix_spawn_file_actions_init 3 , 95.Xr posix_spawnp 3 96.Sh STANDARDS 97These functions conform to 98.St -p1003.1-2001 . 99.Sh AUTHORS 100.An Ed Schouten Aq ed@FreeBSD.org 101