Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
fae20c21
Unverified
Commit
fae20c21
authored
Jul 01, 2018
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
utils: add fd_cloexec()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
Cc: Wolfgang Bumiller <w.bumiller@proxmox.com>
parent
69b0a768
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
0 deletions
+23
-0
utils.c
src/lxc/utils.c
+22
-0
utils.h
src/lxc/utils.h
+1
-0
No files found.
src/lxc/utils.c
View file @
fae20c21
...
@@ -2686,3 +2686,25 @@ void remove_trailing_newlines(char *l)
...
@@ -2686,3 +2686,25 @@ void remove_trailing_newlines(char *l)
while
(
--
p
>=
l
&&
*
p
==
'\n'
)
while
(
--
p
>=
l
&&
*
p
==
'\n'
)
*
p
=
'\0'
;
*
p
=
'\0'
;
}
}
int
fd_cloexec
(
int
fd
,
bool
cloexec
)
{
int
oflags
,
nflags
;
oflags
=
fcntl
(
fd
,
F_GETFD
,
0
);
if
(
oflags
<
0
)
return
-
errno
;
if
(
cloexec
)
nflags
=
oflags
|
FD_CLOEXEC
;
else
nflags
=
oflags
&
~
FD_CLOEXEC
;
if
(
nflags
==
oflags
)
return
0
;
if
(
fcntl
(
fd
,
F_SETFD
,
nflags
)
<
0
)
return
-
errno
;
return
0
;
}
src/lxc/utils.h
View file @
fae20c21
...
@@ -615,5 +615,6 @@ static inline pid_t lxc_raw_gettid(void)
...
@@ -615,5 +615,6 @@ static inline pid_t lxc_raw_gettid(void)
/* Set a signal the child process will receive after the parent has died. */
/* Set a signal the child process will receive after the parent has died. */
extern
int
lxc_set_death_signal
(
int
signal
);
extern
int
lxc_set_death_signal
(
int
signal
);
extern
int
fd_cloexec
(
int
fd
,
bool
cloexec
);
#endif
/* __LXC_UTILS_H */
#endif
/* __LXC_UTILS_H */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment