In current version spawn() function using dummy int f for handling opened TTY - i've changed it to int ftty variable.

[ Damn, sent code as plaintext looks horrible, all in attachements ].

--
Michal Kulling

--- init.c-orig	2014-02-10 20:55:23.942043683 +0100
+++ init.c	2014-02-10 20:56:02.526044600 +0100
@@ -1025,6 +1025,7 @@
   char *args[16];		/* Argv array */
   char buf[136];		/* Line buffer */
   int f, st;			/* Scratch variables */
+  int ftty;			/* Handler for tty controlling */
   char *ptr;			/* Ditto */
   time_t t;			/* System time */
   int oldAlarm;			/* Previous alarm value */
@@ -1154,11 +1155,11 @@
 			 *	of the console after exit of the leader.
 			 */
 			setsid();
-			if ((f = console_open(O_RDWR|O_NOCTTY)) >= 0) {
+			if ((ftty = console_open(O_RDWR|O_NOCTTY)) >= 0) {
 				/* Take over controlling tty by force */
-				(void)ioctl(f, TIOCSCTTY, 1);
-  				dup(f);
-  				dup(f);
+				(void)ioctl(ftty, TIOCSCTTY, 1);
+  				dup(ftty);
+  				dup(ftty);
 			}
 
 			/*
@@ -1192,7 +1193,7 @@
 				 *	Small optimization. See if stealing
 				 *	controlling tty back is needed.
 				 */
-				pgrp = tcgetpgrp(f);
+				pgrp = tcgetpgrp(ftty);
 				if (pgrp != getpid())
 					exit(0);
 
@@ -1207,7 +1208,7 @@
 				}
 				if (pid == 0) {
 					setsid();
-					(void)ioctl(f, TIOCSCTTY, 1);
+					(void)ioctl(ftty, TIOCSCTTY, 1);
 					exit(0);
 				}
 				while((rc = waitpid(pid, &st, 0)) != pid)

Reply via email to