Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Why did we stop at 2? (michaelnygard.com)
2 points by Kinrany on June 16, 2022 | hide | past | favorite | 1 comment


Just so it's clear, fork()/exec() doesn't care if its 2 or 2000: They're all available for inheritance in your copied kernel state.

I used this back in 1985 writing OSI software, to handle the 3,4,5[...] open FD numbers which were the X.25 channel to a front end processor on JANET, or a TCP socket faking out (non) OSI transport layers underneath things.

The problem is knowing WHICH fd # to work with. I hacked it by passing a command line/env argument to the exec() child which specified a list of FD to re-bind into from the inheritance state (not really re-bind: simply call the right sysctl/ioctl to have a named binding to that open FD)

I have a feeling somebody like Marshall Rose took me there, certainly it wasn't entirely un-common to pass open FD beyond the stdin/stdout/stderr around, between things in an IPC dance

Its how parent-child communicate typically: open a pair of FD, mark one for read, one for write, fork/exec, parent reads on 3 and writes on 4, child writes on 3 and reads on 4.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: