Skip to content

Commit d7dd6bd

Browse files
committed
StdlibUnittest: replace a magic value with an optional
1 parent cd312ae commit d7dd6bd

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

stdlib/private/StdlibUnittest/StdlibUnittest.swift.gyb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ func _childProcess() {
670670
}
671671

672672
struct _ParentProcess {
673-
internal var _pid: pid_t = -1
673+
internal var _pid: pid_t? = nil
674674
internal var _childStdin: _FDOutputStream = _FDOutputStream(fd: -1)
675675
internal var _childStdout: _FDInputStream = _FDInputStream(fd: -1)
676676
internal var _childStderr: _FDInputStream = _FDInputStream(fd: -1)
@@ -695,8 +695,8 @@ struct _ParentProcess {
695695
}
696696

697697
mutating func _waitForChild() -> ProcessTerminationStatus {
698-
let status = posixWaitpid(_pid)
699-
_pid = -1
698+
let status = posixWaitpid(_pid!)
699+
_pid = nil
700700
_childStdin.close()
701701
_childStdout.close()
702702
_childStderr.close()
@@ -757,7 +757,7 @@ struct _ParentProcess {
757757
) -> (anyExpectFailed: Bool, seenExpectCrash: Bool,
758758
status: ProcessTerminationStatus?,
759759
crashStdout: [String], crashStderr: [String]) {
760-
if _pid <= 0 {
760+
if _pid == nil {
761761
_spawnChild()
762762
}
763763

0 commit comments

Comments
 (0)