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
a055735a
Unverified
Commit
a055735a
authored
May 24, 2018
by
Stéphane Graber
Committed by
GitHub
May 24, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2348 from brauner/2018-05-24/pthread_sigmask
tree-wide: s/sigprocmask/pthread_sigmask()/g
parents
73b5b70e
eabf1ea9
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
27 additions
and
24 deletions
+27
-24
lxc_init.c
src/lxc/cmd/lxc_init.c
+4
-3
lxc_monitord.c
src/lxc/cmd/lxc_monitord.c
+2
-1
lxccontainer.c
src/lxc/lxccontainer.c
+2
-3
start.c
src/lxc/start.c
+5
-4
terminal.c
src/lxc/terminal.c
+4
-3
utils.c
src/lxc/utils.c
+10
-10
No files found.
src/lxc/cmd/lxc_init.c
View file @
a055735a
...
...
@@ -25,6 +25,7 @@
#include <errno.h>
#include <getopt.h>
#include <libgen.h>
#include <pthread.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
...
...
@@ -266,7 +267,7 @@ int main(int argc, char *argv[])
if
(
ret
<
0
)
exit
(
EXIT_FAILURE
);
ret
=
sigproc
mask
(
SIG_SETMASK
,
&
mask
,
&
omask
);
ret
=
pthread_sig
mask
(
SIG_SETMASK
,
&
mask
,
&
omask
);
if
(
ret
<
0
)
exit
(
EXIT_FAILURE
);
...
...
@@ -340,7 +341,7 @@ int main(int argc, char *argv[])
}
}
ret
=
sigproc
mask
(
SIG_SETMASK
,
&
omask
,
NULL
);
ret
=
pthread_sig
mask
(
SIG_SETMASK
,
&
omask
,
NULL
);
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to set signal mask"
);
exit
(
EXIT_FAILURE
);
...
...
@@ -368,7 +369,7 @@ int main(int argc, char *argv[])
if
(
ret
<
0
)
exit
(
EXIT_FAILURE
);
ret
=
sigproc
mask
(
SIG_SETMASK
,
&
omask
,
NULL
);
ret
=
pthread_sig
mask
(
SIG_SETMASK
,
&
omask
,
NULL
);
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to set signal mask"
);
exit
(
EXIT_FAILURE
);
...
...
src/lxc/cmd/lxc_monitord.c
View file @
a055735a
...
...
@@ -24,6 +24,7 @@
#define _GNU_SOURCE
#include <errno.h>
#include <fcntl.h>
#include <pthread.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
...
...
@@ -386,7 +387,7 @@ int main(int argc, char *argv[])
sigdelset
(
&
mask
,
SIGSEGV
)
||
sigdelset
(
&
mask
,
SIGBUS
)
||
sigdelset
(
&
mask
,
SIGTERM
)
||
sigproc
mask
(
SIG_BLOCK
,
&
mask
,
NULL
))
{
pthread_sig
mask
(
SIG_BLOCK
,
&
mask
,
NULL
))
{
SYSERROR
(
"Failed to set signal mask."
);
exit
(
EXIT_FAILURE
);
}
...
...
src/lxc/lxccontainer.c
View file @
a055735a
...
...
@@ -2000,11 +2000,10 @@ static bool do_lxcapi_shutdown(struct lxc_container *c, int timeout)
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
;
else
if
(
task_blocking_signal
(
pid
,
(
SIGRTMIN
+
3
)))
haltsignal
=
(
SIGRTMIN
+
3
);
/* Add a new state client before sending the shutdown signal so that we
* don't miss a state.
...
...
src/lxc/start.c
View file @
a055735a
...
...
@@ -32,6 +32,7 @@
#include <fcntl.h>
#include <grp.h>
#include <poll.h>
#include <pthread.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
...
...
@@ -314,7 +315,7 @@ static int setup_signal_fd(sigset_t *oldmask)
return
-
EBADF
;
}
ret
=
sigproc
mask
(
SIG_BLOCK
,
&
mask
,
oldmask
);
ret
=
pthread_sig
mask
(
SIG_BLOCK
,
&
mask
,
oldmask
);
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to set signal mask"
);
return
-
EBADF
;
...
...
@@ -860,7 +861,7 @@ int lxc_init(const char *name, struct lxc_handler *handler)
return
0
;
out_restore_sigmask:
sigproc
mask
(
SIG_SETMASK
,
&
handler
->
oldmask
,
NULL
);
pthread_sig
mask
(
SIG_SETMASK
,
&
handler
->
oldmask
,
NULL
);
out_delete_tty:
lxc_delete_tty
(
&
conf
->
ttys
);
out_aborting:
...
...
@@ -986,7 +987,7 @@ void lxc_fini(const char *name, struct lxc_handler *handler)
}
/* Reset mask set by setup_signal_fd. */
ret
=
sigproc
mask
(
SIG_SETMASK
,
&
handler
->
oldmask
,
NULL
);
ret
=
pthread_sig
mask
(
SIG_SETMASK
,
&
handler
->
oldmask
,
NULL
);
if
(
ret
<
0
)
WARN
(
"%s - Failed to restore signal mask"
,
strerror
(
errno
));
...
...
@@ -1064,7 +1065,7 @@ static int do_start(void *data)
goto
out_warn_father
;
}
ret
=
sigproc
mask
(
SIG_SETMASK
,
&
handler
->
oldmask
,
NULL
);
ret
=
pthread_sig
mask
(
SIG_SETMASK
,
&
handler
->
oldmask
,
NULL
);
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to set signal mask"
);
goto
out_warn_father
;
...
...
src/lxc/terminal.c
View file @
a055735a
...
...
@@ -24,6 +24,7 @@
#include <errno.h>
#include <fcntl.h>
#include <lxc/lxccontainer.h>
#include <pthread.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
...
...
@@ -172,7 +173,7 @@ struct lxc_terminal_state *lxc_terminal_signal_init(int srcfd, int dstfd)
goto
on_error
;
}
ret
=
sigproc
mask
(
SIG_BLOCK
,
&
mask
,
&
ts
->
oldmask
);
ret
=
pthread_sig
mask
(
SIG_BLOCK
,
&
mask
,
&
ts
->
oldmask
);
if
(
ret
<
0
)
{
WARN
(
"Failed to block signals"
);
goto
on_error
;
...
...
@@ -181,7 +182,7 @@ struct lxc_terminal_state *lxc_terminal_signal_init(int srcfd, int dstfd)
ts
->
sigfd
=
signalfd
(
-
1
,
&
mask
,
SFD_CLOEXEC
);
if
(
ts
->
sigfd
<
0
)
{
WARN
(
"Failed to create signal fd"
);
sigproc
mask
(
SIG_SETMASK
,
&
ts
->
oldmask
,
NULL
);
(
void
)
pthread_sig
mask
(
SIG_SETMASK
,
&
ts
->
oldmask
,
NULL
);
goto
on_error
;
}
...
...
@@ -206,7 +207,7 @@ void lxc_terminal_signal_fini(struct lxc_terminal_state *ts)
if
(
ts
->
sigfd
>=
0
)
{
close
(
ts
->
sigfd
);
if
(
sigproc
mask
(
SIG_SETMASK
,
&
ts
->
oldmask
,
NULL
)
<
0
)
if
(
pthread_sig
mask
(
SIG_SETMASK
,
&
ts
->
oldmask
,
NULL
)
<
0
)
WARN
(
"%s - Failed to restore signal mask"
,
strerror
(
errno
));
}
...
...
src/lxc/utils.c
View file @
a055735a
...
...
@@ -31,6 +31,7 @@
#include <grp.h>
#include <inttypes.h>
#include <libgen.h>
#include <pthread.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
...
...
@@ -495,7 +496,7 @@ struct lxc_popen_FILE *lxc_popen(const char *command)
if
(
ret
<
0
)
_exit
(
EXIT_FAILURE
);
ret
=
sigproc
mask
(
SIG_UNBLOCK
,
&
mask
,
NULL
);
ret
=
pthread_sig
mask
(
SIG_UNBLOCK
,
&
mask
,
NULL
);
if
(
ret
<
0
)
_exit
(
EXIT_FAILURE
);
...
...
@@ -1813,17 +1814,16 @@ int lxc_count_file_lines(const char *fn)
/* Check whether a signal is blocked by a process. */
/* /proc/pid-to-str/status\0 = (5 + 21 + 7 + 1) */
#define __PROC_STATUS_LEN (
5
+ (LXC_NUMSTRLEN64) + 7 + 1)
#define __PROC_STATUS_LEN (
6
+ (LXC_NUMSTRLEN64) + 7 + 1)
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
;
char
status
[
__PROC_STATUS_LEN
];
FILE
*
f
;
long
unsigned
int
sigblk
=
0
;
size_t
n
=
0
;
bool
bret
=
false
;
char
*
line
=
NULL
;
ret
=
snprintf
(
status
,
__PROC_STATUS_LEN
,
"/proc/%d/status"
,
pid
);
if
(
ret
<
0
||
ret
>=
__PROC_STATUS_LEN
)
...
...
@@ -1834,10 +1834,10 @@ bool task_blocking_signal(pid_t pid, int signal)
return
bret
;
while
(
getline
(
&
line
,
&
n
,
f
)
!=
-
1
)
{
if
(
strncmp
(
line
,
"SigBlk:
\t
"
,
8
))
if
(
strncmp
(
line
,
"SigBlk:
"
,
7
))
continue
;
if
(
sscanf
(
line
+
8
,
"%lx"
,
&
sigblk
)
!=
1
)
if
(
sscanf
(
line
+
7
,
"%lx"
,
&
sigblk
)
!=
1
)
goto
out
;
}
...
...
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