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
1fd0f41e
Unverified
Commit
1fd0f41e
authored
Feb 19, 2018
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
utils: add lxc_set_death_signal()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
46800e77
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
26 deletions
+29
-26
start.c
src/lxc/start.c
+0
-26
utils.c
src/lxc/utils.c
+26
-0
utils.h
src/lxc/utils.h
+3
-0
No files found.
src/lxc/start.c
View file @
1fd0f41e
...
...
@@ -996,32 +996,6 @@ void lxc_abort(const char *name, struct lxc_handler *handler)
}
}
static
int
lxc_set_death_signal
(
int
signal
)
{
int
ret
;
pid_t
ppid
;
ret
=
prctl
(
PR_SET_PDEATHSIG
,
signal
,
0
,
0
,
0
);
/* Check whether we have been orphaned. */
ppid
=
(
pid_t
)
syscall
(
SYS_getppid
);
if
(
ppid
==
1
)
{
pid_t
self
;
self
=
lxc_raw_getpid
();
ret
=
kill
(
self
,
SIGKILL
);
if
(
ret
<
0
)
return
-
1
;
}
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to set PR_SET_PDEATHSIG to %d"
,
signal
);
return
-
1
;
}
return
0
;
}
static
int
do_start
(
void
*
data
)
{
int
ret
;
...
...
src/lxc/utils.c
View file @
1fd0f41e
...
...
@@ -2510,3 +2510,29 @@ uint64_t lxc_find_next_power2(uint64_t n)
n
=
n
<<
1
;
return
n
;
}
int
lxc_set_death_signal
(
int
signal
)
{
int
ret
;
pid_t
ppid
;
ret
=
prctl
(
PR_SET_PDEATHSIG
,
signal
,
0
,
0
,
0
);
/* Check whether we have been orphaned. */
ppid
=
(
pid_t
)
syscall
(
SYS_getppid
);
if
(
ppid
==
1
)
{
pid_t
self
;
self
=
lxc_raw_getpid
();
ret
=
kill
(
self
,
SIGKILL
);
if
(
ret
<
0
)
return
-
1
;
}
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to set PR_SET_PDEATHSIG to %d"
,
signal
);
return
-
1
;
}
return
0
;
}
src/lxc/utils.h
View file @
1fd0f41e
...
...
@@ -589,4 +589,7 @@ static inline pid_t lxc_raw_gettid(void)
#endif
}
/* Set a signal the child process will receive after the parent has died. */
extern
int
lxc_set_death_signal
(
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