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
3cf7d8c2
Unverified
Commit
3cf7d8c2
authored
Feb 09, 2019
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lxc-init: use cleanup macros
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
57e76250
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
14 deletions
+10
-14
Makefile.am
src/lxc/Makefile.am
+2
-0
lxc_init.c
src/lxc/cmd/lxc_init.c
+8
-14
No files found.
src/lxc/Makefile.am
View file @
3cf7d8c2
...
...
@@ -363,6 +363,7 @@ init_lxc_SOURCES = cmd/lxc_init.c \
compiler.h
\
error.h
\
initutils.c initutils.h
\
memory_utils.h
\
parse.c parse.h
\
raw_syscalls.c raw_syscalls.h
\
string_utils.c string_utils.h
...
...
@@ -411,6 +412,7 @@ init_lxc_static_SOURCES = cmd/lxc_init.c \
file_utils.c file_utils.h
\
log.c log.h
\
macro.h
\
memory_utils.h
\
namespace.c namespace.h
\
string_utils.c string_utils.h
...
...
src/lxc/cmd/lxc_init.c
View file @
3cf7d8c2
...
...
@@ -47,6 +47,7 @@
#include "config.h"
#include "error.h"
#include "initutils.h"
#include "memory_utils.h"
#include "parse.h"
#include "raw_syscalls.h"
#include "string_utils.h"
...
...
@@ -100,10 +101,10 @@ static struct arguments my_args = {
static
void
prevent_forking
(
void
)
{
FILE
*
f
;
size_t
len
=
0
;
char
*
line
=
NULL
;
__do_free
char
*
line
=
NULL
;
__do_fclose
FILE
*
f
=
NULL
;
char
path
[
PATH_MAX
];
size_t
len
=
0
;
f
=
fopen
(
"/proc/self/cgroup"
,
"r"
);
if
(
!
f
)
...
...
@@ -138,14 +139,14 @@ static void prevent_forking(void)
if
(
ret
<
0
||
(
size_t
)
ret
>=
sizeof
(
path
))
{
if
(
my_args
.
quiet
)
fprintf
(
stderr
,
"Failed to create string
\n
"
);
goto
on_error
;
return
;
}
fd
=
open
(
path
,
O_WRONLY
);
if
(
fd
<
0
)
{
if
(
my_args
.
quiet
)
fprintf
(
stderr
,
"Failed to open
\"
%s
\"\n
"
,
path
);
goto
on_error
;
return
;
}
ret
=
write
(
fd
,
"1"
,
1
);
...
...
@@ -153,17 +154,13 @@ static void prevent_forking(void)
fprintf
(
stderr
,
"Failed to write to
\"
%s
\"\n
"
,
path
);
close
(
fd
);
break
;
return
;
}
on_error:
free
(
line
);
fclose
(
f
);
}
static
void
kill_children
(
pid_t
pid
)
{
FILE
*
f
;
__do_fclose
FILE
*
f
=
NULL
;
char
path
[
PATH_MAX
];
int
ret
;
...
...
@@ -187,15 +184,12 @@ static void kill_children(pid_t pid)
if
(
fscanf
(
f
,
"%d "
,
&
find_pid
)
!=
1
)
{
if
(
my_args
.
quiet
)
fprintf
(
stderr
,
"Failed to retrieve pid
\n
"
);
fclose
(
f
);
return
;
}
(
void
)
kill_children
(
find_pid
);
(
void
)
kill
(
find_pid
,
SIGKILL
);
}
fclose
(
f
);
}
static
void
remove_self
(
void
)
...
...
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