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 1051161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:53:15+00:00 2026-05-16T16:53:15+00:00

Some POSIX functions are not threadsafe. Examples are dirname and pathname. The dirname() function

  • 0

Some POSIX functions are not threadsafe. Examples are dirname and pathname.

The dirname() function need not be reentrant. A function that is not required to be reentrant is not required to be thread-safe.

On some platforms there are reentrant versions of dirname and pathname: dirname_r and pathname_r.
As far as I found out there are not reentrant version of dirname and pathname on Linux.

  • Is that correct?
  • What is the alternative?
  • 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-05-16T16:53:16+00:00Added an answer on May 16, 2026 at 4:53 pm

    I’m not aware of reentrant versions of dirname and basename in Linux.

    However, there’s various reentrant implementations of both functions in different non-standard libraries.

    g_path_get_dirname and g_path_get_basename from glib are probably commonly used, and their implementation doesn’t depend too much on the rest of the glib library either, so it’d be easy enough to just borrow from their implementation if you don’t particularly feel like linking against glib.

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

Sidebar

Related Questions

I am testing kernel asynchronous io functions (not posix aio) and am trying to
Does anyone have experience with Linux aio functions (io_*, not posix aio)? It would
(With signal handler I mean slots, not handlers for POSIX signals.) I need to
I'm trying to write some code using posix threads but I'm stuck from the
Specifically, I'm using the Linux command: $ find . -regextype posix-extended -regex '<some regex>'
Some time ago I've read an article on CLR, where author showed that if
I have to use an extern library providing lots of free functions that do
I started studying POSIX timers, so I started also doing some exercises, but I
Many standard C and POSIX functions return -1 for error, and 0 on success,
I am trying to create a timer to profile some functions. For example, #include

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.