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
8ca7b374
Unverified
Commit
8ca7b374
authored
Feb 28, 2018
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
terminal: lxc_terminal_set_stdfds()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
1a443ac1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
16 deletions
+21
-16
terminal.c
src/lxc/terminal.c
+21
-16
No files found.
src/lxc/terminal.c
View file @
8ca7b374
...
@@ -931,28 +931,33 @@ err:
...
@@ -931,28 +931,33 @@ err:
return
-
ENODEV
;
return
-
ENODEV
;
}
}
int
lxc_terminal_set_stdfds
(
int
fd
)
static
bool
__terminal_dup2
(
int
duplicate
,
int
original
)
{
{
if
(
fd
<
0
)
int
ret
;
return
0
;
if
(
isatty
(
STDIN_FILENO
))
if
(
!
isatty
(
original
))
if
(
dup2
(
fd
,
STDIN_FILENO
)
<
0
)
{
return
true
;
SYSERROR
(
"failed to duplicate stdin."
);
return
-
1
;
}
if
(
isatty
(
STDOUT_FILENO
))
ret
=
dup2
(
duplicate
,
original
);
if
(
dup2
(
fd
,
STDOUT_FILENO
)
<
0
)
{
if
(
ret
<
0
)
{
SYSERROR
(
"failed to duplicate stdout."
);
SYSERROR
(
"Failed to dup2(%d, %d)"
,
duplicate
,
original
);
return
-
1
;
return
false
;
}
}
if
(
isatty
(
STDERR_FILENO
))
return
true
;
if
(
dup2
(
fd
,
STDERR_FILENO
)
<
0
)
{
}
SYSERROR
(
"failed to duplicate stderr."
);
int
lxc_terminal_set_stdfds
(
int
fd
)
{
int
i
;
if
(
fd
<
0
)
return
0
;
for
(
i
=
0
;
i
<
3
;
i
++
)
if
(
!
__terminal_dup2
(
fd
,
(
int
[]){
STDIN_FILENO
,
STDOUT_FILENO
,
STDERR_FILENO
}[
i
]))
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