logoalt Hacker News

sanderjdtoday at 3:26 PM4 repliesview on HN

I just ran into this recently, where I had an obscure bug caused by needing to close more file descriptors in the forked process. "I want a clone of the current process" is just way less common in my experience than "I want a completely new process". It feels crazy that we don't have a way to directly express the latter thing, and can only approximate it by cloning and then fixing things up in post.


Replies

1718627440today at 3:50 PM

But you generally want to communicate with that process, so you do need to setup e.g. file descriptors and stuff, which needs information from the parent process to be passed.

show 3 replies
dnwtoday at 3:28 PM

What do you mean by "a completely new process"?

show 2 replies
stabblestoday at 4:04 PM

Isn't that covered by O_CLOEXEC?

show 1 reply
7jjjjjjjtoday at 5:00 PM

>It feels crazy that we don't have a way to directly express the latter thing

Isn't that what posix_spawn is for?

show 2 replies