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
ed38feee
Commit
ed38feee
authored
Jul 10, 2017
by
Christian Brauner
Committed by
GitHub
Jul 10, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1690 from brauner/2017-07-10/lifeng68-Modify_fds
start: dup std{in,out,err} to pty slave
parents
1a6cb1ce
bbbf65ee
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
7 deletions
+23
-7
start.c
src/lxc/start.c
+13
-4
utils.c
src/lxc/utils.c
+10
-3
No files found.
src/lxc/start.c
View file @
ed38feee
...
@@ -1063,8 +1063,13 @@ static int do_start(void *data)
...
@@ -1063,8 +1063,13 @@ static int do_start(void *data)
* setup on its console ie. the pty allocated in lxc_console_create() so
* setup on its console ie. the pty allocated in lxc_console_create() so
* make sure that that pty is stdin,stdout,stderr.
* make sure that that pty is stdin,stdout,stderr.
*/
*/
if
(
lxc_console_set_stdfds
(
handler
->
conf
->
console
.
slave
)
<
0
)
if
(
handler
->
conf
->
console
.
slave
>=
0
)
goto
out_warn_father
;
if
(
set_stdfds
(
handler
->
conf
->
console
.
slave
)
<
0
)
{
ERROR
(
"Failed to redirect std{in,out,err} to pty file "
"descriptor %d"
,
handler
->
conf
->
console
.
slave
);
goto
out_warn_father
;
}
/* If we mounted a temporary proc, then unmount it now. */
/* If we mounted a temporary proc, then unmount it now. */
tmp_proc_unmount
(
handler
->
conf
);
tmp_proc_unmount
(
handler
->
conf
);
...
@@ -1142,8 +1147,12 @@ static int do_start(void *data)
...
@@ -1142,8 +1147,12 @@ static int do_start(void *data)
goto
out_warn_father
;
goto
out_warn_father
;
}
}
if
(
handler
->
backgrounded
&&
set_stdfds
(
devnull_fd
))
if
(
handler
->
conf
->
console
.
slave
<
0
&&
handler
->
backgrounded
)
goto
out_warn_father
;
if
(
set_stdfds
(
devnull_fd
)
<
0
)
{
ERROR
(
"Failed to redirect std{in,out,err} to "
"
\"
/dev/null
\"
"
);
goto
out_warn_father
;
}
if
(
devnull_fd
>=
0
)
{
if
(
devnull_fd
>=
0
)
{
close
(
devnull_fd
);
close
(
devnull_fd
);
...
...
src/lxc/utils.c
View file @
ed38feee
...
@@ -1822,14 +1822,21 @@ int open_devnull(void)
...
@@ -1822,14 +1822,21 @@ int open_devnull(void)
int
set_stdfds
(
int
fd
)
int
set_stdfds
(
int
fd
)
{
{
int
ret
;
if
(
fd
<
0
)
if
(
fd
<
0
)
return
-
1
;
return
-
1
;
if
(
dup2
(
fd
,
0
)
<
0
)
ret
=
dup2
(
fd
,
STDIN_FILENO
);
if
(
ret
<
0
)
return
-
1
;
return
-
1
;
if
(
dup2
(
fd
,
1
)
<
0
)
ret
=
dup2
(
fd
,
STDOUT_FILENO
);
if
(
ret
<
0
)
return
-
1
;
return
-
1
;
if
(
dup2
(
fd
,
2
)
<
0
)
ret
=
dup2
(
fd
,
STDERR_FILENO
);
if
(
ret
<
0
)
return
-
1
;
return
-
1
;
return
0
;
return
0
;
...
...
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