On Sat Jun 3 19:52:43 2023 +0000, Chip Davis wrote:
I do not have a macOS system to test on. If someone could confirm
(in)correct behavior of `open(2)` on macOS, I would very much appreciate it. I do have a Mac, and I can confirm that `open(2)`ing a socket file fails with `EOPNOTSUPP`. (Your test program almost compiled successfully; the macOS version of `struct sockaddr` has an additional `sa_len` member that I had to account for to make it work.) Interesting. I took that parenthetical expression in the man pages--and macOS has the same caveat on its `open(2)` man page--to mean that `open(2)`ing a socket was originally intended to work, but just wasn't implemented yet; but you interpreted it to mean that *the behavior itself* wasn't implemented yet. I may need to look into the history of the `open(2)` syscall on a local-domain socket file, to see if 4.2BSD returned `EOPNOTSUPP` in this case.
Turns out, 4.2BSD [*did*, in fact, implement this behavior](https://minnie.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/ufs_sys...). Its [man page](https://minnie.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/man/man2/open.2) also lists `EOPNOTSUPP` as a possible error, with the same parenthetical caveat.