]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commitdiff
fix: CTRL+C/CTRL+Z job control and doom build errors
authorTulio A M Mendes <[email protected]>
Tue, 17 Feb 2026 07:30:53 +0000 (04:30 -0300)
committerTulio A M Mendes <[email protected]>
Tue, 17 Feb 2026 07:30:53 +0000 (04:30 -0300)
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.

user/doom/Makefile
user/sh.c
user/ulibc/include/sys/stat.h

index 3e10aa2e9535573aa4c5884ea296e5df4375a9b7..ab51cd28116ee02c4359956ef7a40a5159fa6f88 100644 (file)
@@ -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
index 051b4d0ce6bc3177dce41156410c8f7369efae2a..14ff5f4e020180c127fe20c7bd4f99012c903d43 100644 (file)
--- 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 */
index e75e08c862127f8af18774010c6b3c65501fe885..02b9d89b74f475946ffcf8104876d0b207fa74a9 100644 (file)
@@ -40,6 +40,9 @@ struct stat {
 #define S_IWOTH 0002
 #define S_IXOTH 0001
 
-/* stat/fstat/mkdir declared in <unistd.h> 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