Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
4lDO2
acid
Commits
79ca7e88
Verified
Commit
79ca7e88
authored
Jun 15, 2020
by
jD91mZM2
Browse files
Additional checks related to cloning/forking
parent
0aa7ee80
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main.rs
View file @
79ca7e88
...
...
@@ -317,18 +317,22 @@ pub fn ptrace() -> Result<(), String> {
assert
!
((
f
-
5.65685424949238
)
.abs
()
<
std
::
f64
::
EPSILON
);
println!
(
"Testing fork event"
);
e
(
next
(
&
mut
tracer
,
Flags
::
STOP_PRE_SYSCALL
|
Flags
::
EVENT_CLONE
))
?
;
assert_eq!
(
e
(
e
(
next
(
&
mut
tracer
,
Flags
::
STOP_PRE_SYSCALL
|
Flags
::
EVENT_CLONE
))
?
.regs
.get_int
())
?
.rax
,
syscall
::
SYS_CLONE
)
;
let
mut
handler
=
e
(
tracer
.next_event
(
Flags
::
STOP_POST_SYSCALL
|
Flags
::
EVENT_CLONE
))
?
;
let
event
=
e
(
e
(
handler
.pop_one
())
?
.ok_or
(
"Expected event but none occured"
))
?
;
match
event
.data
{
EventData
::
EventClone
(
pid
)
=>
println!
(
"Obtained fork (PID {})"
,
pid
),
let
clone_pid
=
match
event
.data
{
EventData
::
EventClone
(
pid
)
=>
{
println!
(
"Obtained fork (PID {})"
,
pid
);
pid
},
ref
e
=>
return
Err
(
format!
(
"Wrong event type: {:?}"
,
e
))
}
}
;
e
(
handler
.retry
())
?
;
let
event
=
e
(
e
(
handler
.pop_one
())
?
.ok_or
(
"Expected event but none occured"
))
?
;
assert_eq!
(
event
.cause
,
Flags
::
STOP_POST_SYSCALL
);
assert_eq!
(
e
(
tracer
.regs
.get_int
())
?
.rax
,
clone_pid
);
println!
(
"Testing fork event - but actually handling the fork"
);
assert_eq!
(
e
(
e
(
next
(
&
mut
tracer
,
Flags
::
STOP_PRE_SYSCALL
|
Flags
::
EVENT_CLONE
))
?
.regs
.get_int
())
?
.rax
,
syscall
::
SYS_WAITPID
);
...
...
Write
Preview
Supports
Markdown
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