From 1043b0772db97568ff1cc7f6fdde14c1804d3cf9 Mon Sep 17 00:00:00 2001 From: apio Date: Fri, 14 Oct 2022 21:26:46 +0200 Subject: [PATCH] Make libc exit with a specific code if program initialization fails Now you know, if a program exits with code -127 it's libc's fault :) --- libs/libc/src/init.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/libc/src/init.cpp b/libs/libc/src/init.cpp index 9b47e16a..279b8d1e 100644 --- a/libs/libc/src/init.cpp +++ b/libs/libc/src/init.cpp @@ -16,8 +16,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(errno); - if (!*target_stream) exit(errno); + exit(-127); + if (!*target_stream) exit(-127); errno = 0; } else { *target_stream = fdopen(fd, mode); }