3 ms·
chdir is thread-safe, but interacting with the current directory in any context other than parsing command-line arguments is still nearly always a mistake. Ever
by plorkyeran 2y ago
chdir is thread-safe, but interacting with the current directory in any context other than parsing command-line arguments is still nearly always a mistake. Everything past a program's entry point should be working exclusively in absolute paths.
- fanf2 2y agoYeah if you chdir() in a multithreaded program, all cwd-relative file accesses in other threads are fucked. As well as absolute paths, it’s ok to work with descriptor-relative paths using openat() and friends.