[core] save errno before logging if execve() fails

(fdevent_fork_execve())
This commit is contained in:
Glenn Strauss 2020-01-23 19:24:51 -05:00
parent fb74bb7514
commit 12aa0f4c91
1 changed files with 2 additions and 1 deletions

View File

@ -769,12 +769,13 @@ pid_t fdevent_fork_execve(const char *name, char *argv[], char *envp[], int fdin
execve(name, argv, envp ? envp : environ);
int errnum = errno;
if (0 == memcmp(argv[0], "/bin/sh", sizeof("/bin/sh")-1)
&& argv[1] && 0 == memcmp(argv[1], "-c", sizeof("-c")-1))
perror(argv[2]);
else
perror(argv[0]);
_exit(errno);
_exit(errnum);
#else