changeset 1339:330a14a08b51 draft

Use ssize_t which is a signed int and test if read() returns -1.
author Roy Marples <roy@marples.name>
date Sat, 11 Jul 2009 07:03:23 +0000
parents 1c8dffb2d423
children ea09f9473c20
files signals.c
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/signals.c	Wed Jul 08 22:18:39 2009 +0000
+++ b/signals.c	Sat Jul 11 07:03:23 2009 +0000
@@ -67,11 +67,11 @@
 {
 	int sig = -1;
 	char buf[16];
-	size_t bytes;
+	ssize_t bytes;
 
 	memset(buf, 0, sizeof(buf));
 	bytes = read(signal_pipe[0], buf, sizeof(buf));
-	if (bytes >= sizeof(sig))
+	if (bytes >= 0 && bytes >= sizeof(sig))
 		memcpy(&sig, buf, sizeof(sig));
 	return sig;
 }