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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:58:26+00:00 2026-06-05T22:58:26+00:00

Is there a POSIX function that searches PATH for an executable according to the

  • 0

Is there a POSIX function that searches PATH for an executable according to the POSIX spec’s description of the PATH environment variable and returns the absolute path to the executable?

If not, is there a simple, safe, standard, and reliable way to search PATH?

Edit:
glibc’s execvpe() function does its own PATH search, so I’m guessing there isn’t a specific PATH search function defined by the standard.

Edit 2: I don’t want to copy someone else’s code or implement the PATH search myself for a few reasons:

  • DRY
  • More code I have to test and maintain
  • Possible licensing issues
  • POSIX says, “If PATH is unset or is set to null, the path search is implementation-defined.” I would like the behavior in these cases to be consistent with whatever the system does, but I can’t do this if there’s not a standard function I can call.
  • 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-05T22:58:28+00:00Added an answer on June 5, 2026 at 10:58 pm

    Is there a POSIX function that searches PATH for an executable according to the POSIX spec’s description of the PATH environment variable and returns the absolute path to the executable?

    No.

    If not, is there a simple, safe, standard, and reliable way to search PATH?

    Yes and no. Yes, there is a standard for the format of PATH, from which the correctness/reliability of implementations follow.

    No, there is no standard function that does this. Copying code is your best bet.

    If PATH is unset or is set to null, the path search is implementation-defined.

    That means you can’t always portably replicate what execvp does, but searching /bin:/usr/bin is a pretty safe bet. Alternatively, just raise an error in this case.

    (I admit that it would have been nice if POSIX had had this function, but it just isn’t there.)

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

Sidebar

Related Questions

Is there a POSIX function that works like the which command? That is, I
Is there any comparable function like Pos that is not case-sensitive in D2010 (unicode)?
Is there a POSIX function that will give me the size of a directory
Is there any POSIX signals that I could utilize in my Perl program to
There is the POSIX library in c++ support wchar_t? if not, then how is
I know that on MacOSX / PosiX systems, there is atomic-compare-and-swap for C/C++ code
Is there any Delphi D2010 function like PosEx that finds a sub-string inside a
Is there any way to check the granularity of gettimeofday() function provided by POSIX?
I just realized that for a POSIX variable with two decimal places the following
Some POSIX functions are not threadsafe. Examples are dirname and pathname. The dirname() function

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.