Touloudou
Touloudou

Reputation: 2223

Why would std::process::Command::ouput fail?

What would cause std::process:Command::output to fail? If the callee program fails, the error will be captured as part of the resulting Output.stderr, so I guess output will only return an Error if the OS fails to create a new process for some reason? Is that something that I can safely ignore for my simple CLI tool?

Upvotes: 1

Views: 122

Answers (1)

loops
loops

Reputation: 5635

  • There could be some issue opening the binary being executed (i.e. access denied, doesn't exist)
  • When waiting for the process to finish, the waitpid syscall could be interrupted
  • Getting the output involves creating a pipe, which will fail if the file descriptor limit is hit (cat /proc/sys/fs/file-max to check)
  • It also involves opening a file, which will fail if the limit on open files is reached (ulimit -n to check)

You probably only need to worry about the first two: you can't do anything about hitting limits in the kernel.

Upvotes: 1

Related Questions