|
-
October 12th, 2025, 07:52 AM
#1
multithreading and chdir
Hello,
Im going through a code, where, it seems the issue is due to the way threading implemented.
I just know basics of threading
I am trying to understand the affects of multithreading on chdir, and how can it be made threadsafe.
May be these hints help me understand the concept and apply in my issue (code is huge, so I am trying to understand the code base first)
Thanks
pdk5
-
October 12th, 2025, 09:41 AM
#2
Re: multithreading and chdir
Ordinarily, the scope of "chdir" is the whole process. Doing chdir in one thread affects all other threads. It can't be thread safe,
https://learn.microsoft.com/en-us/cp...?view=msvc-170
But the link at the bottom of the page suggests you can alter that behaviour.
TBH, it seems like you need a "currentDir" class which is instanced in each thread. It has a couple of methods
- set the effective current dir for the current thread
- resolve a relative path to an absolute path.
-
October 17th, 2025, 02:26 PM
#3
Re: multithreading and chdir
@Salem thankyou very much for the info and help
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|