From: Tulio A M Mendes Date: Tue, 17 Feb 2026 07:30:53 +0000 (-0300) Subject: fix: CTRL+C/CTRL+Z job control and doom build errors X-Git-Url: https://projects.tadryanom.me/?a=commitdiff_plain;h=510de9ec13ee4663f6584d47dfc218481e5eb3a0;p=AdrOS.git fix: CTRL+C/CTRL+Z job control and doom build errors 1. CTRL+C/CTRL+Z: Shell now calls setsid() instead of setpgid(0,0) to create a proper session. This initializes tty_session_id so TIOCSPGRP can actually set child processes as the foreground group. Previously, TIOCSPGRP silently returned -EPERM because tty_session_id was 0. 2. Doom mkdir: Added mkdir/stat/fstat/chmod declarations to user/ulibc/include/sys/stat.h where POSIX expects them. Doom's m_misc.c includes sys/stat.h for mkdir(). 3. Doom __divdi3: Added libgcc.a to doom link step to provide compiler runtime helpers for 64-bit arithmetic on i386. --- diff --git a/user/doom/Makefile b/user/doom/Makefile index 89fdace3..2b48a003 100644 --- a/user/doom/Makefile +++ b/user/doom/Makefile @@ -32,6 +32,7 @@ CFLAGS := -m32 -O2 -ffreestanding -nostdlib -fPIC -fno-plt \ -I$(ULIBC_INC) -I. -Idoomgeneric/doomgeneric \ -DNORMALUNIX -DLINUX +LIBGCC := $(shell $(CC) -print-libgcc-file-name) LDFLAGS := -m elf_i386 --dynamic-linker=/lib/ld.so -T $(DYN_LINKER) -L$(ULIBC_DIR) -rpath /lib # doomgeneric engine sources (nested inside cloned repo) @@ -69,7 +70,7 @@ check-doomgeneric: fi doom.elf: $(ALL_OBJ) $(CRT0) - @$(LD) $(LDFLAGS) -o $@ $(CRT0) $(ALL_OBJ) -lc + @$(LD) $(LDFLAGS) -o $@ $(CRT0) $(ALL_OBJ) -lc $(LIBGCC) @echo " LD $@" doomgeneric/doomgeneric/%.o: doomgeneric/doomgeneric/%.c diff --git a/user/sh.c b/user/sh.c index 5611f6c1..f436e808 100644 --- a/user/sh.c +++ b/user/sh.c @@ -1007,8 +1007,8 @@ int main(int argc, char** argv, char** envp) { if (!var_get("HOME")) var_set("HOME", "/", 1); - /* Job control: put shell in its own process group and make it fg */ - setpgid(0, 0); + /* Job control: create session + process group, become fg */ + setsid(); set_fg_pgrp(getpgrp()); /* Ignore job control signals in the shell itself */ diff --git a/user/ulibc/include/sys/stat.h b/user/ulibc/include/sys/stat.h index 0600b767..42739674 100644 --- a/user/ulibc/include/sys/stat.h +++ b/user/ulibc/include/sys/stat.h @@ -49,6 +49,9 @@ struct stat { #define S_IWOTH 0002 #define S_IXOTH 0001 -/* stat/fstat/mkdir declared in with void* for struct stat* compatibility */ +int stat(const char* path, struct stat* buf); +int fstat(int fd, struct stat* buf); +int mkdir(const char* path, ...); +int chmod(const char* path, int mode); #endif