diff options
Diffstat (limited to 'src/libc/unistd')
-rw-r--r-- | src/libc/unistd/unistd.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/libc/unistd/unistd.c b/src/libc/unistd/unistd.c index 9735df0..99899ce 100644 --- a/src/libc/unistd/unistd.c +++ b/src/libc/unistd/unistd.c @@ -46,8 +46,9 @@ int execvpe(const char *path, char *const argv[], char *const envp[]) { int execve(const char *path, char *const argv[], char *const envp[]) { FILE *file = fopen(path, "e"); char hdr[4] = {0}; - if (!file) - return -1; + if (!file) { + return errno = ENOENT, -1; + } fread(hdr, 1, 4, file); fseek(file, 0, SEEK_SET); @@ -55,6 +56,7 @@ int execve(const char *path, char *const argv[], char *const envp[]) { if (!memcmp("\x7f""ELF", hdr, 4)) { elf_execf(file, (void*)argv, (void*)envp); fclose(file); + errno = EINVAL; } else if (!memcmp("#!", hdr, 2)) { char buf[256]; fseek(file, 2, SEEK_SET); @@ -64,9 +66,10 @@ int execve(const char *path, char *const argv[], char *const envp[]) { if (endl) *endl = '\0'; execve(buf, (void*)argv, envp); } + } else { + errno = EINVAL; } - errno = EINVAL; return -1; } |