Question

If I chdir within a thread, will that affect the cwd of the parent program?

Était-ce utile?

La solution

Yes.

If you need relative paths in a multithreaded application, it's safest to use the at() versions of functions. For example, openat() is like open():

int openat(int dirfd, const char *pathname, int flags);

The first parameter is the fd to a directory. The path is relative to that directory.

Autres conseils

Yes, the "parent program" (initial thread of the thread's process) will be affected because the current directory is shared by all threads of a process.

http://linux.die.net/man/7/pthreads

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top