[dev] [st] [PATCH 1/2] Do not use switch for fork() call.

From: noname <noname_AT_inventati.org>
Date: Sat, 11 Apr 2015 10:46:38 +0000

---
 st.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/st.c b/st.c
index c48132a..df79e93 100644
--- a/st.c
+++ b/st.c
_AT_@ -1257,11 +1257,10 @@ ttynew(void) {
 	if(openpty(&m, &s, NULL, NULL, &w) < 0)
 		die("openpty failed: %s\n", strerror(errno));
 
-	switch(pid = fork()) {
-	case -1:
+	if((pid = fork()) == -1)
 		die("fork failed\n");
-		break;
-	case 0:
+
+	if(pid == 0) {
 		setsid(); /* create a new process group */
 		dup2(s, STDIN_FILENO);
 		dup2(s, STDOUT_FILENO);
_AT_@ -1271,8 +1270,7 @@ ttynew(void) {
 		close(s);
 		close(m);
 		execsh();
-		break;
-	default:
+	} else {
 		close(s);
 		cmdfd = m;
 		signal(SIGCHLD, sigchld);
_AT_@ -1286,7 +1284,6 @@ ttynew(void) {
 					opt_io, strerror(errno));
 			}
 		}
-		break;
 	}
 }
 
-- 
2.3.5
Received on Sat Apr 11 2015 - 12:46:38 CEST

This archive was generated by hypermail 2.3.0 : Sat Apr 11 2015 - 12:48:07 CEST