libc: Exit with -errno if we fail initialization

This commit is contained in:
apio 2022-11-05 11:56:31 +01:00
parent 9ab3ab7c40
commit cedefaf93d

View File

@ -47,8 +47,8 @@ static void check_for_file(int fd, FILE** target_stream, const char* path, const
{
if (errno == EBADF) *target_stream = fopen(path, mode);
else
exit(-127);
if (!*target_stream) exit(-127);
exit(-errno);
if (!*target_stream) exit(-errno);
errno = 0;
}
else { *target_stream = fdopen(fd, mode); }