Skip to content

Commit 88b7e1e

Browse files
Fallback to argv[0] for ProcessInfo.processName on platforms without specific APIs.
WASI does not provide a specific API to retrieve the process name, so we used `CommandLine.arguments.first` for `ProcessInfo.processName`. After swiftlang#1411, `CommandLine.arguments.first` started using platform-specific APIs to retrieve the process name, but the fallback path with `argv[0]` was removed. This commit restores that fallback for platforms like WASI.
1 parent d1b39d1 commit 88b7e1e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Sources/FoundationEssentials/Platform.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,10 @@ extension Platform {
366366
return String(decodingCString: lpBuffer.baseAddress!, as: UTF16.self)
367367
}
368368
#else
369-
// TODO: Implement for other platforms
370-
return nil
369+
guard let processPath = CommandLine.arguments.first else {
370+
return nil
371+
}
372+
return processPath.lastPathComponent
371373
#endif
372374
}
373375
}

0 commit comments

Comments
 (0)