svn commit: trunk/busybox/shell

vda at busybox.net vda at busybox.net
Fri May 25 14:34:31 UTC 2007


Author: vda
Date: 2007-05-25 07:34:30 -0700 (Fri, 25 May 2007)
New Revision: 18691

Log:
hush: fix 'echo abc`sleep 5`def' + Ctrl-Z and Ctrl-C bugs. +50 bytes of code.


Modified:
   trunk/busybox/shell/hush.c


Changeset:
Modified: trunk/busybox/shell/hush.c
===================================================================
--- trunk/busybox/shell/hush.c	2007-05-25 11:12:32 UTC (rev 18690)
+++ trunk/busybox/shell/hush.c	2007-05-25 14:34:30 UTC (rev 18691)
@@ -2158,7 +2158,10 @@
 		exit(rcode);
 	}
  ret:
-	run_list_level--;
+	if (!--run_list_level && interactive_fd) {
+		signal(SIGTSTP, SIG_IGN);
+		signal(SIGINT, SIG_IGN);
+	}
 #endif
 	debug_printf_exec("run_list_real lvl %d return %d\n", run_list_level + 1, rcode);
 	return rcode;
@@ -3130,7 +3133,9 @@
 {
 	FILE *pf;
 	int pid, channel[2];
-	if (pipe(channel) < 0) bb_perror_msg_and_die("pipe");
+
+	if (pipe(channel) < 0)
+		bb_perror_msg_and_die("pipe");
 #if BB_MMU
 	pid = fork();
 #else
@@ -3144,12 +3149,19 @@
 			dup2(channel[1], 1);
 			close(channel[1]);
 		}
+		/* Prevent it from trying to handle ctrl-z etc */
+		run_list_level = 1;
+		/* Process substitution is not considered to be usual
+		 * 'command execution'.
+		 * SUSv3 says ctrl-Z should be ignored, ctrl-C should not. */
+		/* Not needed, we are relying on it being disabled
+		 * everywhere outside actual command execution. */
+		/*set_jobctrl_sighandler(SIG_IGN);*/
+		set_misc_sighandler(SIG_DFL);
 		_exit(run_list_real(head));   /* leaks memory */
 	}
-	debug_printf("forked child %d\n", pid);
 	close(channel[1]);
 	pf = fdopen(channel[0], "r");
-	debug_printf("pipe on FILE *%p\n", pf);
 	return pf;
 }
 
@@ -3199,9 +3211,9 @@
 	 * at the same time.  That would be a lot of work, and contrary
 	 * to the KISS philosophy of this program. */
 	mark_closed(fileno(p));
-	retcode = pclose(p);
+	retcode = fclose(p);
 	free_pipe_list(inner.list_head, 0);
-	debug_printf("pclosed, retcode=%d\n", retcode);
+	debug_printf("closed FILE from child, retcode=%d\n", retcode);
 	return retcode;
 }
 #endif




More information about the busybox-cvs mailing list