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
f8dd0275
Commit
f8dd0275
authored
Mar 24, 2016
by
Aleksandr Mezin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
utils: split null_stdfds() to open_devnull() and set_stdfds()
Signed-off-by:
Aleksandr Mezin
<
mezin.alexander@gmail.com
>
parent
d1ccb562
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
9 deletions
+28
-9
utils.c
src/lxc/utils.c
+26
-9
utils.h
src/lxc/utils.h
+2
-0
No files found.
src/lxc/utils.c
View file @
f8dd0275
...
@@ -1752,24 +1752,41 @@ domount:
...
@@ -1752,24 +1752,41 @@ domount:
return
1
;
return
1
;
}
}
int
null_stdfds
(
void
)
int
open_devnull
(
void
)
{
{
int
fd
,
ret
=
-
1
;
int
fd
=
open
(
"/dev/null"
,
O_RDWR
);
if
(
fd
<
0
)
SYSERROR
(
"Can't open /dev/null"
);
return
fd
;
}
fd
=
open
(
"/dev/null"
,
O_RDWR
);
int
set_stdfds
(
int
fd
)
{
if
(
fd
<
0
)
if
(
fd
<
0
)
return
-
1
;
return
-
1
;
if
(
dup2
(
fd
,
0
)
<
0
)
if
(
dup2
(
fd
,
0
)
<
0
)
goto
err
;
return
-
1
;
if
(
dup2
(
fd
,
1
)
<
0
)
if
(
dup2
(
fd
,
1
)
<
0
)
goto
err
;
return
-
1
;
if
(
dup2
(
fd
,
2
)
<
0
)
if
(
dup2
(
fd
,
2
)
<
0
)
goto
err
;
return
-
1
;
return
0
;
}
int
null_stdfds
(
void
)
{
int
ret
=
-
1
;
int
fd
=
open_devnull
();
if
(
fd
>=
0
)
{
ret
=
set_stdfds
(
fd
);
close
(
fd
);
}
ret
=
0
;
err
:
close
(
fd
);
return
ret
;
return
ret
;
}
}
...
...
src/lxc/utils.h
View file @
f8dd0275
...
@@ -283,6 +283,8 @@ int setproctitle(char *title);
...
@@ -283,6 +283,8 @@ int setproctitle(char *title);
int
safe_mount
(
const
char
*
src
,
const
char
*
dest
,
const
char
*
fstype
,
int
safe_mount
(
const
char
*
src
,
const
char
*
dest
,
const
char
*
fstype
,
unsigned
long
flags
,
const
void
*
data
,
const
char
*
rootfs
);
unsigned
long
flags
,
const
void
*
data
,
const
char
*
rootfs
);
int
mount_proc_if_needed
(
const
char
*
rootfs
);
int
mount_proc_if_needed
(
const
char
*
rootfs
);
int
open_devnull
(
void
);
int
set_stdfds
(
int
fd
);
int
null_stdfds
(
void
);
int
null_stdfds
(
void
);
int
lxc_count_file_lines
(
const
char
*
fn
);
int
lxc_count_file_lines
(
const
char
*
fn
);
#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