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
aa353b5e
Commit
aa353b5e
authored
Jan 22, 2012
by
alina
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added unit test to check that protocol.Server kills alive children when shutdown.
parent
97e7d152
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
5 deletions
+26
-5
examples/sample.py
examples/sample.py
+0
-0
src/nemu/protocol.py
src/nemu/protocol.py
+5
-5
test/test_protocol.py
test/test_protocol.py
+21
-0
No files found.
sample.py
→
examples/
sample.py
View file @
aa353b5e
File moved
src/nemu/protocol.py
View file @
aa353b5e
...
...
@@ -115,26 +115,26 @@ class Server(object):
# -PID to kill to whole process group
os
.
kill
(
-
pid
,
signal
.
SIGTERM
)
now
=
time
.
time
()
ch
=
set
(
self
.
_children
)
while
time
.
time
()
-
now
<
KILL_WAIT
:
ch
=
set
(
self
.
_children
)
for
pid
in
ch
:
try
:
if
nemu
.
subprocess_
.
poll
(
pid
):
ch
.
remove
(
pid
)
self
.
_children
.
remove
(
pid
)
except
OSError
,
e
:
if
e
.
errno
==
errno
.
ECHILD
:
ch
.
remove
(
pid
)
self
.
_children
.
remove
(
pid
)
else
:
raise
if
not
ch
:
break
time
.
sleep
(
0.1
)
for
pid
in
ch
:
for
pid
in
self
.
_children
:
warning
(
"Killing forcefully process %d."
%
pid
)
# -PID to kill to whole process group
os
.
kill
(
-
pid
,
signal
.
SIGKILL
)
for
pid
in
ch
:
for
pid
in
self
.
_children
:
try
:
nemu
.
subprocess_
.
poll
(
pid
)
except
OSError
,
e
:
...
...
test/test_protocol.py
View file @
aa353b5e
...
...
@@ -43,6 +43,27 @@ class TestServer(unittest.TestCase):
s2
.
close
()
t
.
join
()
def
test_server_clean
(
self
):
(
s0
,
s1
)
=
socket
.
socketpair
(
socket
.
AF_UNIX
,
socket
.
SOCK_STREAM
,
0
)
def
run_server
():
nemu
.
protocol
.
Server
(
s0
,
s0
).
run
()
t
=
threading
.
Thread
(
target
=
run_server
)
t
.
start
()
cli
=
nemu
.
protocol
.
Client
(
s1
,
s1
)
null
=
file
(
'/dev/null'
,
'wb'
)
argv
=
[
'/bin/sh'
,
'-c'
,
'yes'
]
pid
=
cli
.
spawn
(
argv
,
stdout
=
null
)
self
.
assertTrue
(
os
.
path
.
exists
(
"/proc/%d"
%
pid
))
# try to exit while there are still processes running
cli
.
shutdown
()
t
.
join
()
# Check that the process was killed.
# We are asumming that the pid is not going to be reused fast enough
# to generate a false possitive.
self
.
assertFalse
(
os
.
path
.
exists
(
"/proc/%d"
%
pid
))
def
test_spawn_recovery
(
self
):
(
s0
,
s1
)
=
socket
.
socketpair
(
socket
.
AF_UNIX
,
socket
.
SOCK_STREAM
,
0
)
...
...
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