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/docs/static/gitweb.js?a=commitdiff_plain;h=bd9a1b3bf2ddb06c00bc4362191cfe333f096166;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 3e10aa2..ab51cd2 100644 --- a/user/doom/Makefile +++ b/user/doom/Makefile @@ -23,6 +23,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) @@ -60,7 +61,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 051b4d0..14ff5f4 100644 --- a/user/sh.c +++ b/user/sh.c @@ -998,8 +998,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 e75e08c..02b9d89 100644 --- a/user/ulibc/include/sys/stat.h +++ b/user/ulibc/include/sys/stat.h @@ -40,6 +40,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