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.
-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)
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
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 */
#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