square / okio

A modern I/O library for Android, Java, and Kotlin Multiplatform.
https://square.github.io/okio/
Apache License 2.0
8.72k stars 1.17k forks source link

Thoughts on using flag `O_CLOEXEC` for unix source sets? #1447

Open 05nelsonm opened 4 months ago

05nelsonm commented 4 months ago

Wanted to pop in and ask about the possibility of always opening descriptors with the O_CLOEXEC flag, or utilizing the e flag with fopen.

EDIT: Can sling up a PR if it would be an acceptable addition to the library!

swankjesse commented 4 months ago

Yeah, seems quite reasonable. Do you have a specific use case? I’m curious about forking and execing in Kotlin/Native and haven’t seen many examples.

swankjesse commented 4 months ago

Please send a PR!

05nelsonm commented 4 months ago

Do you have a specific use case?

Not really, just thought it'd be an easy win for everyone.

I’m curious about forking and execing in Kotlin/Native and haven’t seen many examples

https://github.com/05nelsonm/kmp-process/blob/master/library/process/src/unixMain/kotlin/io/matthewnelson/kmp/process/internal/PlatformBuilder.kt