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
bafda6b6
Commit
bafda6b6
authored
Jul 19, 2016
by
Serge Hallyn
Committed by
GitHub
Jul 19, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1086 from brauner/detect_sigrtmin_3
[RFC]: lxccontainer: detect if we should send SIGRTMIN+3
parents
31c32ef2
330ae3d3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
0 deletions
+49
-0
lxccontainer.c
src/lxc/lxccontainer.c
+8
-0
utils.c
src/lxc/utils.c
+38
-0
utils.h
src/lxc/utils.h
+3
-0
No files found.
src/lxc/lxccontainer.c
View file @
bafda6b6
...
...
@@ -1604,8 +1604,16 @@ static bool do_lxcapi_shutdown(struct lxc_container *c, int timeout)
pid
=
do_lxcapi_init_pid
(
c
);
if
(
pid
<=
0
)
return
true
;
/* Detect whether we should send SIGRTMIN + 3 (e.g. systemd). */
if
(
task_blocking_signal
(
pid
,
(
SIGRTMIN
+
3
)))
haltsignal
=
(
SIGRTMIN
+
3
);
if
(
c
->
lxc_conf
&&
c
->
lxc_conf
->
haltsignal
)
haltsignal
=
c
->
lxc_conf
->
haltsignal
;
INFO
(
"Using signal number '%d' as halt signal."
,
haltsignal
);
kill
(
pid
,
haltsignal
);
retv
=
do_lxcapi_wait
(
c
,
"STOPPED"
,
timeout
);
return
retv
;
...
...
src/lxc/utils.c
View file @
bafda6b6
...
...
@@ -1838,3 +1838,41 @@ int lxc_strmunmap(void *addr, size_t length)
{
return
munmap
(
addr
,
length
+
1
);
}
/* Check whether a signal is blocked by a process. */
bool
task_blocking_signal
(
pid_t
pid
,
int
signal
)
{
bool
bret
=
false
;
char
*
line
=
NULL
;
long
unsigned
int
sigblk
=
0
;
size_t
n
=
0
;
int
ret
;
FILE
*
f
;
/* The largest integer that can fit into long int is 2^64. This is a
* 20-digit number. */
size_t
len
=
/* /proc */
5
+
/* /pid-to-str */
21
+
/* /status */
7
+
/* \0 */
1
;
char
status
[
len
];
ret
=
snprintf
(
status
,
len
,
"/proc/%d/status"
,
pid
);
if
(
ret
<
0
||
ret
>=
len
)
return
bret
;
f
=
fopen
(
status
,
"r"
);
if
(
!
f
)
return
bret
;
while
(
getline
(
&
line
,
&
n
,
f
)
!=
-
1
)
{
if
(
!
strncmp
(
line
,
"SigBlk:
\t
"
,
8
))
if
(
sscanf
(
line
+
8
,
"%lx"
,
&
sigblk
)
!=
1
)
goto
out
;
}
if
(
sigblk
&
signal
)
bret
=
true
;
out
:
free
(
line
);
fclose
(
f
);
return
bret
;
}
src/lxc/utils.h
View file @
bafda6b6
...
...
@@ -296,4 +296,7 @@ int open_devnull(void);
int
set_stdfds
(
int
fd
);
int
null_stdfds
(
void
);
int
lxc_count_file_lines
(
const
char
*
fn
);
/* Check whether a signal is blocked by a process. */
bool
task_blocking_signal
(
pid_t
pid
,
int
signal
);
#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