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

The Archive Base Latest Questions

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

What are the reasons that an exec (execl,execlp, etc.) can fail? If you make

  • 0

What are the reasons that an exec (execl,execlp, etc.) can fail? If you make a call to exec and it returns, are there any best practices other than just panicking and calling exit?

  • 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-16T22:09:16+00:00Added an answer on May 16, 2026 at 10:09 pm

    From the exec(3) man page:

    The execl(), execle(), execlp(), execvp(), and execvP() functions may fail and set errno for any of the errors specified for the library functions execve(2) and malloc(3).

    The execv() function may fail and set errno for any of the errors specified for the library function execve(2).

    And then from the execve(2) man page:

    ERRORS

    Execve() will fail and return to the calling process if:

    • [E2BIG] – The number of bytes in the new process’s argument list is larger than the system-imposed limit. This limit is specified by the sysctl(3) MIB variable KERN_ARGMAX.
    • [EACCES] – Search permission is denied for a component of the path prefix.
    • [EACCES] – The new process file is not an ordinary file.
    • [EACCES] – The new process file mode denies execute permission.
    • [EACCES] – The new process file is on a filesystem mounted with execution disabled (MNT_NOEXEC in <sys/mount.h>).
    • [EFAULT] – The new process file is not as long as indicated by the size values in its header.
    • [EFAULT] – Path, argv, or envp point to an illegal address.
    • [EIO] – An I/O error occurred while reading from the file system.
    • [ELOOP] – Too many symbolic links were encountered in translating the pathname. This is taken to be indicative of a looping symbolic link.
    • [ENAMETOOLONG] – A component of a pathname exceeded {NAME_MAX} characters, or an entire path name exceeded {PATH_MAX} characters.
    • [ENOENT] – The new process file does not exist.
    • [ENOEXEC] – The new process file has the appropriate access permission, but has an unrecognized format (e.g., an invalid magic number in its header).
    • [ENOMEM] – The new process requires more virtual memory than is allowed by the imposed maximum (getrlimit(2)).
    • [ENOTDIR] – A component of the path prefix is not a directory.
    • [ETXTBSY] – The new process file is a pure procedure (shared text) file that is currently open for writing or reading by some process.

    malloc() is a lot less complicated, and uses only ENOMEM. From the malloc(3) man page:

    If successful, calloc(), malloc(), realloc(), reallocf(), and valloc() functions return a pointer to allocated memory. If there is an error, they return a NULL pointer and set errno to ENOMEM.

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

Sidebar

Related Questions

For reasons that only the developers can understand, Firefox will create and open .url
I suppose there could be historical reasons for this naming and that other languages
It looks like you can't use exec in a function that has a subfunction...
For reasons that we won't discuss, I have determined that MAMP is a pile
For reasons that are irrelevant to this question I'll need to run several SQLite
What are the most common reasons that I would be getting this error from
I would like to know the reasons that we do refactoring and justify it.
In Release It! , Michael Nygard reasons that many catastrophic system failures are often
(Let's assume that I have good reasons not to remove my NSAssert() checks in
I'm writing a program that for performance reasons uses shared memory (sockets and pipes

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.