libc.obj: update exit #340
4 Participants
Notifications
Due Date
No due date set.
Reference: KolibriOS/kolibrios#340
Reference in New Issue
Block a user
Delete Branch "Egor00f/kolibrios:libc.ob--update-exit"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
New functions:
_exit/_Exit.atexit.abort.abortwriteAborted pid: %dto debug boardChanges:
call
exitafter main.Just calling
exitexitwrite exit codeIf exit code isn't 0
exitwill write exit code to debug board.use
con_exit(0)use
instead of
from console.obj readme.
I think the console window shouldn't be so dependent on the exit code. It's must only always close or always stay on screen
exitwriting exit code to debug boardSince the exit code is not used anywhere right now, I think it's better to just show it on the debug board.
for auto rebuild
crt0.oneed #339from #311
@@ -0,0 +1,18 @@#include <stdlib.h>Please add copyright:
@@ -56,2 +57,2 @@jz @f ;чруЁєцхэ√ ърт√ўъшmov dh, ch ;ярЁрьхЄЁ схч ърт√ўхъjz @f ; quotes loadedmov dh, ch ; parameter without quotesPlease fix indent
@@ -0,0 +1,29 @@#include <conio.h>Please add copyright:
@@ -0,0 +1,69 @@#ifndef __STDLIB_EXIT_H__It's actually super redundant. I assume that this serves some purpose, but in native code it is unnecessary.
I add it for
system(). now i thnink will be better add it later.I suspect this is redundant. I saw the code for
system()in the recent PR. You don't have to wait there for the shell to close; you can callshell exitand it will close immediately.In fact, in KolibriOS there are no exit codes, what you are trying to do looks like a dirty hack.
Okay, I'll just delete this. I'll think about it later.
@@ -0,0 +1,12 @@#include <stdio.h>Please add copyright:
@@ -0,0 +1,35 @@#include <stdlib.h>Please add copyright:
@@ -1,12 +1,25 @@/* Copyright (C) 2021 Logaev Maxim (turbocat2001), GPLv2 */Please udate copyright:
@@ -4,1 +4,4 @@#include <sys/ksys.h>#include "_exit.h"static void __close_all()TCC does not optimize the codegen. Comment out and write TODO.
Egor00f referenced this pull request2026-03-07 16:47:40 +00:00
Hmm... maybe it would be better to declare
_exitwith#define? No sdl and some other libraries require it as functionEgor00f referenced this pull request from Lua/Lua2026-03-14 18:03:51 +00:00
91763282f5to384781f570384781f570to7af77fe7f4d786ae0acbto637b030f4b637b030f4btob049f7a28bb049f7a28btofd0f932959Current problems:
Duplicate
#include "stdlib/_exit.c"inlibc.c.Included twice in one amalgamated TU => duplicate definitions of
__libc_exit/_exit=> won't compile.Remove the second include.
crt0.asminclude path../×5 →../×6.File stays in
.../source/crt/;../×5 =programs/proc32.inc(exists),../×6 = repo root (no such file).Breaks
crt0assembly. Keep 5 levels.atexitmissing fromlibc.def.Added to
stdlib.handEXPORTS[]but notlibc.def(unlikeabort/_exit) => export incomplete,atexit_test.cwon't link.Add it.
Trailing-whitespace churn in
crt0.asm.Mostly resolved (the
push_param/.dont_add/section '.bss'/path rb buf_lenchurn was dropped).One stray trailing space remains on an unrelated line:
cmp word ptr eax, 32fh ; '/#3' UTF8.Drop it and this is fully closed.
#define _Exit(status) _exit(status);- trailing;breaksif/else; drop it.void abort();- nowvoid abort(void);instdlib.handabort.c.Unused
WRITE_EXIT_CODE/READ_EXIT_CODEin_exit.h-_exit.hremoved entirely;_exit.crewritten clean._exit.c- new_exit.cends with a newline.exit()printsfprintf(stderr, "Exit code: %d")on nonzero status.Non-standard: C
exit()produces no output. Programs that legitimately exit nonzero (tools returning a status) will now spam stderr. Same class asabort()'s "Aborted pid:" message.Not a bug, but a deliberate, undocumented behavior change - decide to keep it (and document) or drop it.
con_exit(status)→con_exit(0)(behavior change, undocumented).con_exit's argument is a console-close flag, not an exit code; passingstatuswas likely unintentional, socon_exit(0)is probably more correct. But it changes console-close behavior for nonzero-exit programs and is not mentioned in the PR.Confirm intent / note it.
abort_test.c:int main()with noreturn- now ends withreturn 0;.fd0f932959to3486d12d3dexitafter main && translatecrt0.asmand convert it to UTF-8 effec6fd393486d12d3dto425aaee697425aaee697to20d4ddc89a_exit4dfe040da0atexit06aed280e3abort01b50c3c1f19ed6fd049tob77b8ff69f