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