Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document the error cases for std::process::Command #65125

Open
jfrimmel opened this issue Oct 5, 2019 · 1 comment
Open

Document the error cases for std::process::Command #65125

jfrimmel opened this issue Oct 5, 2019 · 1 comment
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools A-process Area: `std::process` and `std::env` C-enhancement Category: An issue proposing an enhancement or a PR with one. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@jfrimmel
Copy link
Contributor

jfrimmel commented Oct 5, 2019

The current documentation of the std::process::Command-struct lacks the description of possible error cases. All examples assume the working case, too.
There is currently no easy was to see, why a e.g. a call to spawn() could fail (before running).

I would recommend to add either a list of possible error cases (if this is similar on every platform) or add links to external documentation, if the different platforms have their own possible error codes.

Unfortunately I cannot help here very much, as I'm not aware of the Process implementations on different platforms, e.g. Windows.

@jonas-schievink jonas-schievink added C-enhancement Category: An issue proposing an enhancement or a PR with one. A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Oct 5, 2019
@workingjubilee workingjubilee added the A-process Area: `std::process` and `std::env` label Jul 22, 2023
@hkBst
Copy link
Member

hkBst commented Mar 4, 2025

While this would surely be nice to have, it also seems like a lot of work. On Linux these are (according to man) the possible errors from execvp (which is currently used according to this comment):

ERRORS
       E2BIG  The total number of bytes in the environment (envp) and argument list (argv) is too large, an argument or environment string is too long, or the full pathname of the executable is too long.  The terminating null byte is counted as part  of
              the string length.

       EACCES Search permission is denied on a component of the path prefix of pathname or the name of a script interpreter.  (See also path_resolution(7).)

       EACCES The file or a script interpreter is not a regular file.

       EACCES Execute permission is denied for the file or a script or ELF interpreter.

       EACCES The filesystem is mounted noexec.

       EAGAIN (since Linux 3.1)
              Having changed its real UID using one of the set*uid() calls, the caller was—and is now still—above its RLIMIT_NPROC resource limit (see setrlimit(2)).  For a more detailed explanation of this error, see NOTES.

       EFAULT pathname or one of the pointers in the vectors argv or envp points outside your accessible address space.

       EINVAL An ELF executable had more than one PT_INTERP segment (i.e., tried to name more than one interpreter).

       EIO    An I/O error occurred.

       EISDIR An ELF interpreter was a directory.

       ELIBBAD
              An ELF interpreter was not in a recognized format.

       ELOOP  Too many symbolic links were encountered in resolving pathname or the name of a script or ELF interpreter.

       ELOOP  The maximum recursion limit was reached during recursive script interpretation (see "Interpreter scripts", above).  Before Linux 3.8, the error produced for this case was ENOEXEC.

       EMFILE The per-process limit on the number of open file descriptors has been reached.

       ENAMETOOLONG
              pathname is too long.

       ENFILE The system-wide limit on the total number of open files has been reached.

       ENOENT The file pathname or a script or ELF interpreter does not exist.

       ENOEXEC
              An executable is not in a recognized format, is for the wrong architecture, or has some other format error that means it cannot be executed.

       ENOMEM Insufficient kernel memory was available.

       ENOTDIR
              A component of the path prefix of pathname or a script or ELF interpreter is not a directory.

       EPERM  The filesystem is mounted nosuid, the user is not the superuser, and the file has the set-user-ID or set-group-ID bit set.

       EPERM  The process is being traced, the user is not the superuser and the file has the set-user-ID or set-group-ID bit set.

       EPERM  A "capability-dumb" applications would not obtain the full set of permitted capabilities granted by the executable file.  See capabilities(7).

       ETXTBSY
              The specified executable was open for writing by one or more processes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools A-process Area: `std::process` and `std::env` C-enhancement Category: An issue proposing an enhancement or a PR with one. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants