Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8177731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:35:08+00:00 2026-06-06T23:35:08+00:00

My question is an extension to the question previously asked here . I need

  • 0

My question is an extension to the question previously asked here.

I need to create a directory tree which may or may not exist earlier and moreover multiple threads can try to create such directory structure. The question cited solves the problem for single threads. Is that function thread safe or are there any specific ways of doing it. I am using C and OS is Ubuntu.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T23:35:10+00:00Added an answer on June 6, 2026 at 11:35 pm

    In libc, mkdir can set the error value EEXIST which means ‘that directory already exists’. Thanks Jonathan Leffler “errno is thread-safe as long as you tell the compilation to make things thread-safe”.

    Creating directories is monotonic – you are always adding new ones, not removing them. So you can create a directory tree (attempting to create each directory at each level) and if some other thread got there first, it’s not a problem, keep going.

    If I were you, I would have each thread create its entire path recursively, ignoring errors. When it is complete building its path, it should then test whether the directory exists. If it does not exist, that is a problem (as the sequence of mkdir operations that you used to create the required path will be synchronous within the thread). If it does exist, congratulations.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is an extension of a question I previously asked here . Long story
This is an extension of the question I asked here I have a relationship
this is an extension to a previous question I asked , today .... which
I've seen this question posted here previously but I'm not satisfied that I understand
this question is an extension of the question here i tried to extend Dane's
This question is an extension to the one raised here: Using factory_girl in Rails
As an extension to this question here Linking JavaScript Libraries in User Controls I
This question already has an answer here: What are Extension Methods? 5 answers Usage
Sorry for the redundancy, I should've asked this in my previous question here: What's
Hello every one this is extension to my previous question.Here is the link File

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.