Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mininet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Olaf Bergmann
mininet
Commits
d4ca1db6
Commit
d4ca1db6
authored
10 years ago
by
Brian O'Connor
Browse files
Options
Downloads
Plain Diff
Merge pull request #364 from cdburkard/patches/testCPULimit
Fix output of backgrounded processes
parents
47d567e5
ce167380
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mininet/net.py
+1
-1
1 addition, 1 deletion
mininet/net.py
mininet/node.py
+12
-7
12 additions, 7 deletions
mininet/node.py
with
13 additions
and
8 deletions
mininet/net.py
+
1
−
1
View file @
d4ca1db6
...
...
@@ -740,7 +740,7 @@ def runCpuLimitTest( self, cpu, duration=5 ):
sleep
(
1
)
outputs
.
append
(
quietRun
(
cmd
).
strip
()
)
for
h
in
hosts
:
h
.
cmd
(
'
kill
%1
'
)
h
.
cmd
(
'
kill
$!
'
)
cpu_fractions
=
[]
for
test_output
in
outputs
:
# Split by line. Ignore first line, which looks like this:
...
...
This diff is collapsed.
Click to expand it.
mininet/node.py
+
12
−
7
View file @
d4ca1db6
...
...
@@ -160,6 +160,7 @@ def startShell( self ):
self
.
pollOut
.
poll
()
self
.
waiting
=
False
self
.
cmd
(
'
stty -echo
'
)
self
.
cmd
(
'
set +m
'
)
def
cleanup
(
self
):
"
Help python collect its garbage.
"
...
...
@@ -238,12 +239,12 @@ def sendCmd( self, *args, **kwargs ):
# Replace empty commands with something harmless
cmd
=
'
echo -n
'
self
.
lastCmd
=
cmd
if
printPid
and
not
isShellBuiltin
(
cmd
):
if
len
(
cmd
)
>
0
and
cmd
[
-
1
]
==
'
&
'
:
# print ^A{pid}\n so monitor() can set lastPid
cmd
+=
'
printf
"
\\
001%d
\
n
"
$!
\n
'
else
:
cmd
=
'
mnexec -p
'
+
cmd
#
if
a builtin command is backgrounded, it still yields a PID
if
len
(
cmd
)
>
0
and
cmd
[
-
1
]
==
'
&
'
:
# print ^A{pid}\n so monitor() can set lastPid
cmd
+=
'
printf
"
\\
001%d
\
\
012
"
$!
'
elif
printPid
and
not
isShellBuiltin
(
cmd
)
:
cmd
=
'
mnexec -p
'
+
cmd
self
.
write
(
cmd
+
'
\n
'
)
self
.
lastPid
=
None
self
.
waiting
=
True
...
...
@@ -258,9 +259,13 @@ def monitor( self, timeoutms=None, findPid=True ):
timeoutms: timeout in ms or None to wait indefinitely.
"""
self
.
waitReadable
(
timeoutms
)
data
=
self
.
read
(
1024
)
pidre
=
r
'
\[\d+\] \d+\r\n
'
# Look for PID
marker
=
chr
(
1
)
+
r
'
\d+\r\n
'
if
findPid
and
chr
(
1
)
in
data
:
# suppress the job and PID of a backgrounded command
if
re
.
findall
(
pidre
,
data
):
data
=
re
.
sub
(
pidre
,
''
,
data
)
# Marker can be read in chunks; continue until all of it is read
while
not
re
.
findall
(
marker
,
data
):
data
+=
self
.
read
(
1024
)
...
...
@@ -1264,7 +1269,7 @@ def start( self ):
if
self
.
cdir
is
not
None
:
self
.
cmd
(
'
cd
'
+
self
.
cdir
)
self
.
cmd
(
self
.
command
+
'
'
+
self
.
cargs
%
self
.
port
+
'
1>
'
+
cout
+
'
2>
'
+
cout
+
'
&
'
)
'
1>
'
+
cout
+
'
2>
'
+
cout
+
'
&
'
)
self
.
execed
=
False
def
stop
(
self
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment