Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nemu3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
nemu3
Commits
ed07c351
Commit
ed07c351
authored
Jun 06, 2011
by
alina
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
subprocess: kills the whole process group when exits to avoid leaving unkilled forked processes
parent
94ce2805
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
4 deletions
+11
-4
src/netns/protocol.py
src/netns/protocol.py
+7
-4
src/netns/subprocess_.py
src/netns/subprocess_.py
+4
-0
No files found.
src/netns/protocol.py
View file @
ed07c351
...
...
@@ -96,7 +96,8 @@ class Server(object):
def
clean
(
self
):
try
:
for
pid
in
self
.
_children
:
os
.
kill
(
pid
,
signal
.
SIGTERM
)
# -PID to kill to whole process group
os
.
kill
(
-
pid
,
signal
.
SIGTERM
)
now
=
time
.
time
()
ch
=
self
.
_children
while
time
.
time
()
-
now
<
KILL_WAIT
:
...
...
@@ -115,7 +116,8 @@ class Server(object):
for
pid
in
ch
:
warning
(
"Killing forcefully process %d."
%
pid
)
os
.
kill
(
pid
,
signal
.
SIGKILL
)
# -PID to kill to whole process group
os
.
kill
(
-
pid
,
signal
.
SIGKILL
)
for
pid
in
ch
:
try
:
netns
.
subprocess_
.
poll
(
pid
)
...
...
@@ -410,9 +412,10 @@ class Server(object):
self
.
reply
(
500
,
"Process does not exist."
)
return
if
signal
:
os
.
kill
(
pid
,
sig
)
# -PID to kill to whole process group
os
.
kill
(
-
pid
,
sig
)
else
:
os
.
kill
(
pid
,
signal
.
SIGTERM
)
os
.
kill
(
-
pid
,
signal
.
SIGTERM
)
self
.
reply
(
200
,
"Process signalled."
)
def
do_IF_LIST
(
self
,
cmdname
,
ifnr
=
None
):
...
...
src/netns/subprocess_.py
View file @
ed07c351
...
...
@@ -316,6 +316,10 @@ def spawn(executable, argv = None, cwd = None, env = None, close_fds = False,
for
i
in
close_fds
:
os
.
close
(
i
)
# changing process group id
# (it is necessary to kill the forked subprocesses)
os
.
setpgrp
()
if
user
!=
None
:
# Change user
os
.
setgid
(
gid
)
...
...
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