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
9b10bef5
Unverified
Commit
9b10bef5
authored
Oct 20, 2018
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
start: simplify
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
b8ab4849
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
11 deletions
+18
-11
start.c
src/lxc/start.c
+18
-11
No files found.
src/lxc/start.c
View file @
9b10bef5
...
@@ -180,8 +180,6 @@ static bool lxc_try_preserve_namespaces(struct lxc_handler *handler,
...
@@ -180,8 +180,6 @@ static bool lxc_try_preserve_namespaces(struct lxc_handler *handler,
fd
=
lxc_try_preserve_ns
(
pid
,
ns_info
[
i
].
proc_name
);
fd
=
lxc_try_preserve_ns
(
pid
,
ns_info
[
i
].
proc_name
);
if
(
fd
<
0
)
{
if
(
fd
<
0
)
{
handler
->
nsfd
[
i
]
=
-
EBADF
;
/* Do not fail to start container on kernels that do
/* Do not fail to start container on kernels that do
* not support interacting with namespaces through
* not support interacting with namespaces through
* /proc.
* /proc.
...
@@ -295,7 +293,6 @@ restart:
...
@@ -295,7 +293,6 @@ restart:
static
int
setup_signal_fd
(
sigset_t
*
oldmask
)
static
int
setup_signal_fd
(
sigset_t
*
oldmask
)
{
{
int
ret
;
int
ret
;
int
sig
;
sigset_t
mask
;
sigset_t
mask
;
const
int
signals
[]
=
{
SIGBUS
,
SIGILL
,
SIGSEGV
,
SIGWINCH
};
const
int
signals
[]
=
{
SIGBUS
,
SIGILL
,
SIGSEGV
,
SIGWINCH
};
...
@@ -304,7 +301,7 @@ static int setup_signal_fd(sigset_t *oldmask)
...
@@ -304,7 +301,7 @@ static int setup_signal_fd(sigset_t *oldmask)
if
(
ret
<
0
)
if
(
ret
<
0
)
return
-
EBADF
;
return
-
EBADF
;
for
(
sig
=
0
;
sig
<
(
sizeof
(
signals
)
/
sizeof
(
signals
[
0
]));
sig
++
)
{
for
(
int
sig
=
0
;
sig
<
(
sizeof
(
signals
)
/
sizeof
(
signals
[
0
]));
sig
++
)
{
ret
=
sigdelset
(
&
mask
,
signals
[
sig
]);
ret
=
sigdelset
(
&
mask
,
signals
[
sig
]);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
-
EBADF
;
return
-
EBADF
;
...
@@ -377,13 +374,15 @@ static int signal_handler(int fd, uint32_t events, void *data,
...
@@ -377,13 +374,15 @@ static int signal_handler(int fd, uint32_t events, void *data,
if
(
siginfo
.
ssi_signo
==
SIGHUP
)
{
if
(
siginfo
.
ssi_signo
==
SIGHUP
)
{
kill
(
hdlr
->
pid
,
SIGTERM
);
kill
(
hdlr
->
pid
,
SIGTERM
);
INFO
(
"Killing %d since terminal hung up"
,
hdlr
->
pid
);
INFO
(
"Killing %d since terminal hung up"
,
hdlr
->
pid
);
return
hdlr
->
init_died
?
LXC_MAINLOOP_CLOSE
:
LXC_MAINLOOP_CONTINUE
;
return
hdlr
->
init_died
?
LXC_MAINLOOP_CLOSE
:
LXC_MAINLOOP_CONTINUE
;
}
}
if
(
siginfo
.
ssi_signo
!=
SIGCHLD
)
{
if
(
siginfo
.
ssi_signo
!=
SIGCHLD
)
{
kill
(
hdlr
->
pid
,
siginfo
.
ssi_signo
);
kill
(
hdlr
->
pid
,
siginfo
.
ssi_signo
);
INFO
(
"Forwarded signal %d to pid %d"
,
siginfo
.
ssi_signo
,
hdlr
->
pid
);
INFO
(
"Forwarded signal %d to pid %d"
,
siginfo
.
ssi_signo
,
hdlr
->
pid
);
return
hdlr
->
init_died
?
LXC_MAINLOOP_CLOSE
:
LXC_MAINLOOP_CONTINUE
;
return
hdlr
->
init_died
?
LXC_MAINLOOP_CLOSE
:
LXC_MAINLOOP_CONTINUE
;
}
}
/* More robustness, protect ourself from a SIGCHLD sent
/* More robustness, protect ourself from a SIGCHLD sent
...
@@ -392,18 +391,24 @@ static int signal_handler(int fd, uint32_t events, void *data,
...
@@ -392,18 +391,24 @@ static int signal_handler(int fd, uint32_t events, void *data,
if
(
siginfo
.
ssi_pid
!=
hdlr
->
pid
)
{
if
(
siginfo
.
ssi_pid
!=
hdlr
->
pid
)
{
NOTICE
(
"Received %d from pid %d instead of container init %d"
,
NOTICE
(
"Received %d from pid %d instead of container init %d"
,
siginfo
.
ssi_signo
,
siginfo
.
ssi_pid
,
hdlr
->
pid
);
siginfo
.
ssi_signo
,
siginfo
.
ssi_pid
,
hdlr
->
pid
);
return
hdlr
->
init_died
?
LXC_MAINLOOP_CLOSE
:
LXC_MAINLOOP_CONTINUE
;
return
hdlr
->
init_died
?
LXC_MAINLOOP_CLOSE
:
LXC_MAINLOOP_CONTINUE
;
}
}
if
(
siginfo
.
ssi_code
==
CLD_STOPPED
)
{
if
(
siginfo
.
ssi_code
==
CLD_STOPPED
)
{
INFO
(
"Container init process was stopped"
);
INFO
(
"Container init process was stopped"
);
return
hdlr
->
init_died
?
LXC_MAINLOOP_CLOSE
:
LXC_MAINLOOP_CONTINUE
;
return
hdlr
->
init_died
?
LXC_MAINLOOP_CLOSE
}
else
if
(
siginfo
.
ssi_code
==
CLD_CONTINUED
)
{
:
LXC_MAINLOOP_CONTINUE
;
}
if
(
siginfo
.
ssi_code
==
CLD_CONTINUED
)
{
INFO
(
"Container init process was continued"
);
INFO
(
"Container init process was continued"
);
return
hdlr
->
init_died
?
LXC_MAINLOOP_CLOSE
:
LXC_MAINLOOP_CONTINUE
;
return
hdlr
->
init_died
?
LXC_MAINLOOP_CLOSE
:
LXC_MAINLOOP_CONTINUE
;
}
}
DEBUG
(
"Container init process %d exited"
,
hdlr
->
pid
);
DEBUG
(
"Container init process %d exited"
,
hdlr
->
pid
);
return
LXC_MAINLOOP_CLOSE
;
return
LXC_MAINLOOP_CLOSE
;
}
}
...
@@ -649,6 +654,9 @@ void lxc_free_handler(struct lxc_handler *handler)
...
@@ -649,6 +654,9 @@ void lxc_free_handler(struct lxc_handler *handler)
if
(
handler
->
state_socket_pair
[
1
]
>=
0
)
if
(
handler
->
state_socket_pair
[
1
]
>=
0
)
close
(
handler
->
state_socket_pair
[
1
]);
close
(
handler
->
state_socket_pair
[
1
]);
if
(
handler
->
cgroup_ops
)
cgroup_exit
(
handler
->
cgroup_ops
);
handler
->
conf
=
NULL
;
handler
->
conf
=
NULL
;
free
(
handler
);
free
(
handler
);
handler
=
NULL
;
handler
=
NULL
;
...
@@ -959,7 +967,6 @@ void lxc_fini(const char *name, struct lxc_handler *handler)
...
@@ -959,7 +967,6 @@ void lxc_fini(const char *name, struct lxc_handler *handler)
cgroup_ops
->
payload_destroy
(
cgroup_ops
,
handler
);
cgroup_ops
->
payload_destroy
(
cgroup_ops
,
handler
);
cgroup_ops
->
monitor_destroy
(
cgroup_ops
,
handler
);
cgroup_ops
->
monitor_destroy
(
cgroup_ops
,
handler
);
cgroup_exit
(
cgroup_ops
);
if
(
handler
->
conf
->
reboot
==
REBOOT_NONE
)
{
if
(
handler
->
conf
->
reboot
==
REBOOT_NONE
)
{
/* For all new state clients simply close the command socket.
/* For all new state clients simply close the command socket.
...
...
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