3 ms·
errno is in thread-local storage (TLS)
by Vogtinator 1y ago
errno is in thread-local storage (TLS)
- amelius 1y agoYes. It is too bad that they didn't use a similar solution for the current working directory. Chdir() is process-wide, not thread local :(
- o11c 1y ago`openat` has basically solved that since 2.6.16 (which came out in 2006). There are still some uncommon APIs have been slow to gain `at` variants but there's usually a workaround (for example, `getxattrat` and family were only added in 6.13 (this January), but can be implemented in terms of `openat` + `fgetxattr`)
- hvenev 1y ago> can be implemented in terms of `openat` + `fgetxattr` Except for symlinks. `fgetxattr` requires a file opened for read or write, but symlinks can only be opened as `O_PATH`.
- account42 1y agoThis is good because the current directory conceptually process wide for the user as well. If your program isn't a shell or performs a similar function then you probably should not change the working directory at all. If you need thread-specific local paths just use one of the *at() variants that let you explicitly specify a directory handle that your path is relative to.
- wahern 1y agoNotably, the POSIX Threads API itself (i.e. pthread_ routines) returns errors directly rather than through errno.
- JdeBP 1y agoIt was a common design of new operating system APIs, not encumbered by PDP-11 compatibility, in the 1980s. * https://tty0.social/@JdeBP/114816928464571239 https://tty0.social/@JdeBP/114816928464571239 Even some of the later augmentations in MS/PC/DR-DOS did things like return an error code in AX and the result in (say) CX instead of using AX and CF.
- deleted 1y ago[deleted]