Dup()'s shared file IO offset is a necessary part of Unix
utcc.utoronto.ca
utcc.utoronto.ca
Here's the file struct in Linux (f_pos is the file offset):
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/lin...
And here's the fd array in Linux (note file descriptors are indexes into fd_array which is an array of pointers to struct file):
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/lin...
=> The dup() function provides an alternative interface to the service provided by fcntl() using the F_DUPFD command. The call dup(fildes) shall be equivalent to:
=> fcntl(fildes, F_DUPFD, 0);
-- https://pubs.opengroup.org/onlinepubs/9699919799/
Going to fcntl() docs,
=> The new file descriptor shall refer to the same open file description as the original file descriptor, and shall share any locks
-- https://pubs.opengroup.org/onlinepubs/9699919799/functions/f...
Which implies being exactly the same kernel data structure for the file description, with all its current state.
The problem with a "here is what Linux does" response is that it actually bespeaks of the respondent not knowing enough. Linux isn't even relevant, as M. Siebenmann is talking of design decisions made 20 years before Linux was even conceived.
Whereas there were contemporary operating systems that used everything from file control blocks to file handles, and did not have these semantics. Nor indeed did they have the higher-level command processor semantics that they enabled.
The question M. Siebenmann was posing is in part whether it was inevitable that multi-process operating system designs ended up with these particular shared file pointer semantics, or just an accident of the fact that we got the idea of shared "standard" I/O streams long before we got the idea of forcing all sequential-access write operations to always append with a flag.