From 9f6b2744216253fd5f7e7c8f1479abb42e2c3c68 Mon Sep 17 00:00:00 2001
From: John Hodge <tpg@mutabah.net>
Date: Thu, 20 Oct 2011 12:01:10 +0800
Subject: [PATCH] Applications/cat - Added error check

---
 Usermode/Applications/Makefile.tpl   | 2 +-
 Usermode/Applications/cat_src/main.c | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/Usermode/Applications/Makefile.tpl b/Usermode/Applications/Makefile.tpl
index 13397655..542fd815 100644
--- a/Usermode/Applications/Makefile.tpl
+++ b/Usermode/Applications/Makefile.tpl
@@ -4,7 +4,7 @@
 #
 
 CFLAGS  += -Wall -Werror -fno-builtin -fno-stack-protector -g
-LDFLAGS += 
+LDFLAGS += -g
 
 _BIN := $(OUTPUTDIR)$(DIR)/$(BIN)
 _OBJPREFIX := obj-$(ARCH)/
diff --git a/Usermode/Applications/cat_src/main.c b/Usermode/Applications/cat_src/main.c
index e63a97c1..a389c108 100644
--- a/Usermode/Applications/cat_src/main.c
+++ b/Usermode/Applications/cat_src/main.c
@@ -30,6 +30,7 @@ int main(int argc, char *argv[])
 
 	do {
 		num = read(fd, buf, BUF_SIZE);
+		if(num < 0)	break;
 		buf[num] = '\0';
 		printf("%s", buf);
 	} while(num == BUF_SIZE);
-- 
GitLab