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
6dae6815
Commit
6dae6815
authored
Feb 24, 2010
by
Daniel Lezcano
Committed by
Daniel Lezcano
Feb 24, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
factor-out-console code
Factor out the console code and encapsulate the code in functions. Signed-off-by:
Daniel Lezcano
<
dlezcano@fr.ibm.com
>
parent
236087a6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
24 deletions
+43
-24
lxc_console.c
src/lxc/lxc_console.c
+43
-24
No files found.
src/lxc/lxc_console.c
View file @
6dae6815
...
@@ -100,11 +100,43 @@ static void sigwinch(int sig)
...
@@ -100,11 +100,43 @@ static void sigwinch(int sig)
winsz
();
winsz
();
}
}
static
int
setup_tios
(
int
fd
,
struct
termios
*
newtios
,
struct
termios
*
oldtios
)
{
if
(
isatty
(
fd
))
{
ERROR
(
"'%d' is not a tty"
,
fd
);
return
-
1
;
}
/* Get current termios */
if
(
tcgetattr
(
0
,
oldtios
))
{
SYSERROR
(
"failed to get current terminal settings"
);
return
-
1
;
}
*
newtios
=
*
oldtios
;
/* Remove the echo characters and signal reception, the echo
* will be done below with master proxying */
newtios
->
c_iflag
&=
~
IGNBRK
;
newtios
->
c_iflag
&=
BRKINT
;
newtios
->
c_lflag
&=
~
(
ECHO
|
ICANON
|
ISIG
);
newtios
->
c_cc
[
VMIN
]
=
1
;
newtios
->
c_cc
[
VTIME
]
=
0
;
/* Set new attributes */
if
(
tcsetattr
(
0
,
TCSAFLUSH
,
newtios
))
{
ERROR
(
"failed to set new terminal settings"
);
return
-
1
;
}
return
0
;
}
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
int
wait4q
=
0
;
int
wait4q
=
0
;
int
err
;
int
err
;
struct
termios
tios
,
oldtios
;
struct
termios
new
tios
,
oldtios
;
err
=
lxc_arguments_parse
(
&
my_args
,
argc
,
argv
);
err
=
lxc_arguments_parse
(
&
my_args
,
argc
,
argv
);
if
(
err
)
if
(
err
)
...
@@ -114,27 +146,8 @@ int main(int argc, char *argv[])
...
@@ -114,27 +146,8 @@ int main(int argc, char *argv[])
my_args
.
progname
,
my_args
.
quiet
))
my_args
.
progname
,
my_args
.
quiet
))
return
-
1
;
return
-
1
;
/* Get current termios */
if
(
setup_tios
(
0
,
&
newtios
,
&
oldtios
))
{
if
(
tcgetattr
(
0
,
&
tios
))
{
ERROR
(
"failed to setup tios"
);
ERROR
(
"failed to get current terminal settings : %s"
,
strerror
(
errno
));
return
-
1
;
}
oldtios
=
tios
;
/* Remove the echo characters and signal reception, the echo
* will be done below with master proxying */
tios
.
c_iflag
&=
~
IGNBRK
;
tios
.
c_iflag
&=
BRKINT
;
tios
.
c_lflag
&=
~
(
ECHO
|
ICANON
|
ISIG
);
tios
.
c_cc
[
VMIN
]
=
1
;
tios
.
c_cc
[
VTIME
]
=
0
;
/* Set new attributes */
if
(
tcsetattr
(
0
,
TCSAFLUSH
,
&
tios
))
{
ERROR
(
"failed to set new terminal settings : %s"
,
strerror
(
errno
));
return
-
1
;
return
-
1
;
}
}
...
@@ -145,8 +158,14 @@ int main(int argc, char *argv[])
...
@@ -145,8 +158,14 @@ int main(int argc, char *argv[])
fprintf
(
stderr
,
"
\n
Type <Ctrl+%c q> to exit the console
\n
"
,
fprintf
(
stderr
,
"
\n
Type <Ctrl+%c q> to exit the console
\n
"
,
'a'
+
my_args
.
escape
-
1
);
'a'
+
my_args
.
escape
-
1
);
setsid
();
if
(
setsid
())
signal
(
SIGWINCH
,
sigwinch
);
INFO
(
"already group leader"
);
if
(
signal
(
SIGWINCH
,
sigwinch
)
==
SIG_ERR
)
{
SYSERROR
(
"failed to set SIGWINCH handler"
);
return
-
1
;
}
winsz
();
winsz
();
err
=
0
;
err
=
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