Skip to content

Commit 255a395

Browse files
committed
[Backtracing] Handle EINTR while trying to create a crash log.
Mike rightly points out that it's possible for `open()` to fail with `EINTR`, which we should handle here. rdar://136977833
1 parent 9bdd9e7 commit 255a395

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

stdlib/public/libexec/swift-backtrace/main.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,10 @@ Generate a backtrace for the parent process.
563563

564564
var fd = open(filename, O_RDWR|O_CREAT|O_EXCL, 0o644)
565565
var ndx = 1
566-
while fd < 0 && errno == EEXIST {
567-
ndx += 1
566+
while fd < 0 && (errno == EEXIST || errno == EINTR) {
567+
if errno != EINTR {
568+
ndx += 1
569+
}
568570
filename = "\(args.outputPath)/\(name)-\(pid)-\(now.tv_sec).\(now.tv_nsec)-\(ndx).log"
569571
fd = open(filename, O_RDWR|O_CREAT|O_EXCL, 0o644)
570572
}

0 commit comments

Comments
 (0)