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
d61197e8
Unverified
Commit
d61197e8
authored
Nov 06, 2019
by
Stéphane Graber
Committed by
GitHub
Nov 06, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3180 from brauner/2019-11-06/terminal_fixes
terminal: bugfixes
parents
e07039d1
1ba4ae89
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
37 deletions
+22
-37
terminal.c
src/lxc/terminal.c
+22
-23
terminal.h
src/lxc/terminal.h
+0
-14
No files found.
src/lxc/terminal.c
View file @
d61197e8
...
...
@@ -115,8 +115,8 @@ int lxc_terminal_signalfd_cb(int fd, uint32_t events, void *cbdata,
struct
lxc_terminal_state
*
lxc_terminal_signal_init
(
int
srcfd
,
int
dstfd
)
{
__do_close_prot_errno
int
signal_fd
=
-
EBADF
;
__do_free
struct
lxc_terminal_state
*
ts
=
NULL
;
bool
istty
=
false
;
int
ret
;
sigset_t
mask
;
...
...
@@ -132,52 +132,51 @@ struct lxc_terminal_state *lxc_terminal_signal_init(int srcfd, int dstfd)
ret
=
sigemptyset
(
&
mask
);
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to initialize an empty signal set"
);
goto
on_error
;
return
NULL
;
}
istty
=
(
isatty
(
srcfd
)
==
1
);
if
(
!
istty
)
{
INFO
(
"fd %d does not refer to a tty device"
,
srcfd
);
}
else
{
if
(
isatty
(
srcfd
))
{
ret
=
sigaddset
(
&
mask
,
SIGWINCH
);
if
(
ret
<
0
)
SYSNOTICE
(
"Failed to add SIGWINCH to signal set"
);
}
else
{
INFO
(
"fd %d does not refer to a tty device"
,
srcfd
);
}
/* Exit the mainloop cleanly on SIGTERM. */
ret
=
sigaddset
(
&
mask
,
SIGTERM
);
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to add SIGWINCH to signal set"
);
goto
on_error
;
return
NULL
;
}
ret
=
pthread_sigmask
(
SIG_BLOCK
,
&
mask
,
&
ts
->
oldmask
);
if
(
ret
<
0
)
{
WARN
(
"Failed to block signals"
);
goto
on_error
;
return
NULL
;
}
ts
->
sig
fd
=
signalfd
(
-
1
,
&
mask
,
SFD_CLOEXEC
);
if
(
ts
->
sig
fd
<
0
)
{
signal_
fd
=
signalfd
(
-
1
,
&
mask
,
SFD_CLOEXEC
);
if
(
signal_
fd
<
0
)
{
WARN
(
"Failed to create signal fd"
);
(
void
)
pthread_sigmask
(
SIG_SETMASK
,
&
ts
->
oldmask
,
NULL
);
goto
on_error
;
}
DEBUG
(
"Created signal fd %d"
,
ts
->
sigfd
);
return
ts
;
on_error:
ERROR
(
"Failed to create signal fd"
);
if
(
ts
->
sigfd
>=
0
)
{
close
(
ts
->
sigfd
);
ts
->
sigfd
=
-
1
;
return
NULL
;
}
ts
->
sigfd
=
move_fd
(
signal_fd
);
TRACE
(
"Created signal fd %d"
,
ts
->
sigfd
);
return
NULL
;
return
move_ptr
(
ts
)
;
}
void
lxc_terminal_signal_fini
(
struct
lxc_terminal
*
terminal
)
/**
* lxc_terminal_signal_fini: uninstall signal handler
*
* @terminal: terminal instance
*
* Restore the saved signal handler that was in effect at the time
* lxc_terminal_signal_init() was called.
*/
static
void
lxc_terminal_signal_fini
(
struct
lxc_terminal
*
terminal
)
{
struct
lxc_terminal_state
*
state
=
terminal
->
tty_state
;
...
...
src/lxc/terminal.h
View file @
d61197e8
...
...
@@ -262,20 +262,6 @@ extern struct lxc_terminal_state *lxc_terminal_signal_init(int srcfd, int dstfd)
extern
int
lxc_terminal_signalfd_cb
(
int
fd
,
uint32_t
events
,
void
*
cbdata
,
struct
lxc_epoll_descr
*
descr
);
/**
* lxc_terminal_signal_fini: uninstall signal handler
*
* @terminal
* - the lxc_terminal
*
* Restore the saved signal handler that was in effect at the time
* lxc_terminal_signal_init() was called.
*
* Must be called with process_lock held to protect the lxc_ttys list, or
* from a non-threaded context.
*/
extern
void
lxc_terminal_signal_fini
(
struct
lxc_terminal
*
terminal
);
extern
int
lxc_terminal_write_ringbuffer
(
struct
lxc_terminal
*
terminal
);
extern
int
lxc_terminal_create_log_file
(
struct
lxc_terminal
*
terminal
);
extern
int
lxc_terminal_io_cb
(
int
fd
,
uint32_t
events
,
void
*
data
,
...
...
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