daemon: ‘runProgram’ exits with 127 upon ENOENT or similar.

This is in accordance with widespread conventions.  Previously it would
exit with code 1, which was misleading.

* nix/libutil/util.cc (runProgram): Exit with 127 if ‘execv’ or ‘execvp’
fails.

Change-Id: I5df214afffda69aa329a25afbc48f6cbfdd0961c
This commit is contained in:
Ludovic Courtès 2025-06-10 11:45:31 +02:00
parent 512920e7a3
commit c7b8f3ec1a
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -1193,7 +1193,9 @@ string runProgram(Path program, bool searchPath, const Strings & args)
else
execv(program.c_str(), stringsToCharPtrs(args_).data());
throw SysError(format("executing `%1%'") % program);
int err = errno;
printMsg(lvlError, format("executing `%1%': %2%") % program % strerror(err));
_exit(127);
});
pipe.writeSide.close();