File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed
tools/swift-inspect/Sources/SwiftInspectLinux Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -33,24 +33,25 @@ public struct PTrace: ~Copyable {
33
33
// process by calling cont().
34
34
// NOTE: clients must use withPTracedProcess instead of direct initialization.
35
35
fileprivate init ( _ pid: pid_t ) throws {
36
- guard ptrace_attach ( pid) != - 1 else {
37
- throw PTraceError . operationFailure ( PTRACE_ATTACH, pid: pid)
36
+ self . pid = pid
37
+
38
+ guard ptrace_attach ( self . pid) != - 1 else {
39
+ throw PTraceError . operationFailure ( PTRACE_ATTACH, pid: self . pid)
38
40
}
39
41
40
42
while true {
41
43
var status : CInt = 0
42
- let result = waitpid ( pid, & status, 0 )
44
+ let result = waitpid ( self . pid, & status, 0 )
43
45
if result == - 1 {
44
46
if get_errno ( ) == EINTR { continue }
45
- throw PTraceError . waitFailure ( pid: pid)
47
+ throw PTraceError . waitFailure ( pid: self . pid)
46
48
}
47
49
48
- precondition ( pid == result, " waitpid returned unexpected value \( result) " )
50
+ precondition ( self . pid == result,
51
+ " waitpid returned unexpected value \( result) " )
49
52
50
53
if wIfStopped ( status) { break }
51
54
}
52
-
53
- self . pid = pid
54
55
}
55
56
56
57
deinit { _ = ptrace_detach ( self . pid) }
You can’t perform that action at this time.
0 commit comments