From 7ae762e4f146f4d97bf8d50b6569c5cfcb622c7e Mon Sep 17 00:00:00 2001 From: czjstmax Date: Thu, 19 Mar 2026 18:44:16 +0100 Subject: added debug stuff and fixed ^C Signed-off-by: czjstmax --- Makefile | 10 +++++++--- nm.c | 10 ++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 8140274..37d7840 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,15 @@ CC = gcc IN = nm.c OUT = nshm -LIBS = -lreadline -OPTS = -O0 -g -Wall -Wextra -pedantic +LIBS = -lreadline +OPTS = -O2 -Wall -Wextra -pedantic +OPTSDBG = -O0 -g -Wall -Wextra -pedantic + +debug: + $(CC) -o$(OUT) $(LIBS) $(OPTSDBG) $(IN) all: - $(CC) -o$(OUT) $(LIBS) $(OPTS) $(IN) + $(CC) -o$(OUT) $(LIBS) $(OPTS) $(IN) run: all ./$(OUT) diff --git a/nm.c b/nm.c index 75949b1..455fd0e 100644 --- a/nm.c +++ b/nm.c @@ -106,7 +106,7 @@ int main(void) waitpid(pid, &status, 0); } else { - printf("nsh+! couldn't open %s", p.we_wordv[0]); + fprintf(stderr, "nsh+! ERROR: couldn't execute %s\n", p.we_wordv[0]); } } } @@ -114,9 +114,11 @@ int main(void) void handlecc(int sig) { - printf("\nnsh+! %d caught.\nfreeing stuff before quitting.\n", sig); - FreeAll(); - exit(0); + (void)sig; + rl_replace_line("", 0); + printf("\n"); + rl_on_new_line(); + rl_redisplay(); } void FreeAll() -- cgit v1.3.1