shithub: plan9front

Download patch

ref: 7c1e0be91969ab0d8fca4bd1fd52de32f4a9a0c5
parent: ee289c241577a3553bfd73211cd81e137ab4fe40
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Tue May 4 19:50:09 EDT 2021

cpu: properly handle end of file in readstr()

--- a/sys/src/cmd/cpu.c	Sat May  1 13:58:58 2021
+++ b/sys/src/cmd/cpu.c	Tue May  4 19:50:09 2021
@@ -430,6 +430,10 @@
 		n = read(fd, str, 1);
 		if(n < 0) 
 			return -1;
+		if(n == 0){
+			werrstr("hung up");
+			return -1;
+		}
 		if(*str == '\0')
 			return 0;
 		str++;