| ▲ | supermdguy 4 hours ago | |
Reading the code, I was surprised to see that cd was implemented by calling out to the os library. I assumed that was something the shell or at least userspace handled. At what level does the concept of a “current directory” exist? | ||
| ▲ | creatonez 4 hours ago | parent | next [-] | |
It's at the kernel level. Each process has its own current working directory. On Linux, these CWD values are exposed at `/proc/[...]/cwd`. This value affects the resolution of relative paths in filesystem operations at a syscall level. | ||
| ▲ | lukeh 4 hours ago | parent | prev | next [-] | |
In the kernel’s process structure. See NOTES - https://man7.org/linux/man-pages/man2/chdir.2.html | ||
| ▲ | semiquaver 4 hours ago | parent | prev [-] | |
Unix defines a Working Directory that every process has, changed with chdir(2): https://man7.org/linux/man-pages/man2/chdir.2.html | ||