svn commit: trunk/busybox/shell

vda at busybox.net vda at busybox.net
Mon Jan 22 07:30:28 UTC 2007


Author: vda
Date: 2007-01-21 23:30:26 -0800 (Sun, 21 Jan 2007)
New Revision: 17447

Log:
cmdedit: stop playing dirty games with atexit


Modified:
   trunk/busybox/shell/cmdedit.c


Changeset:
Modified: trunk/busybox/shell/cmdedit.c
===================================================================
--- trunk/busybox/shell/cmdedit.c	2007-01-22 07:21:38 UTC (rev 17446)
+++ trunk/busybox/shell/cmdedit.c	2007-01-22 07:30:26 UTC (rev 17447)
@@ -1097,6 +1097,8 @@
 	char c;
 	char *pbuf;
 
+	cmdedit_prmt_len = 0;
+
 	if (!pwd_buf) {
 		pwd_buf = (char *)bb_msg_unknown;
 	}
@@ -1212,14 +1214,6 @@
 
 static sighandler_t previous_SIGWINCH_handler;
 
-static void cmdedit_reset_term(void)
-{
-	setTermSettings(STDIN_FILENO, (void *) &initial_settings);
-	/* restore SIGWINCH handler */
-	signal(SIGWINCH, previous_SIGWINCH_handler);
-	fflush(stdout);
-}
-
 static void cmdedit_setwidth(unsigned w, int redraw_flg)
 {
 	cmdedit_termw = w;
@@ -1241,32 +1235,6 @@
 		signal(SIGWINCH, win_changed); /* rearm ourself */
 }
 
-static void cmdedit_init(void)
-{
-	cmdedit_prmt_len = 0;
-	previous_SIGWINCH_handler = signal(SIGWINCH, win_changed);
-	win_changed(0); /* do initial resizing */
-
-#if ENABLE_FEATURE_GETUSERNAME_AND_HOMEDIR
-	{
-		struct passwd *entry;
-
-		entry = getpwuid(geteuid());
-		if (entry) {
-			user_buf = xstrdup(entry->pw_name);
-			home_pwd_buf = xstrdup(entry->pw_dir);
-		}
-	}
-#endif
-
-#if ENABLE_FEATURE_COMMAND_TAB_COMPLETION
-	my_uid = getuid();
-	my_gid = getgid();
-#endif
-// Crap. We should be able to do it without atexit.
-	atexit(cmdedit_reset_term);     /* be sure to do this only once */
-}
-
 /*
  * The emacs and vi modes share much of the code in the big
  * command loop.  Commands entered when in vi's command mode (aka
@@ -1329,7 +1297,23 @@
 	setTermSettings(0, (void *) &new_settings);
 
 	/* Now initialize things */
-	cmdedit_init();
+	previous_SIGWINCH_handler = signal(SIGWINCH, win_changed);
+	win_changed(0); /* do initial resizing */
+#if ENABLE_FEATURE_GETUSERNAME_AND_HOMEDIR
+	{
+		struct passwd *entry;
+
+		entry = getpwuid(geteuid());
+		if (entry) {
+			user_buf = xstrdup(entry->pw_name);
+			home_pwd_buf = xstrdup(entry->pw_dir);
+		}
+	}
+#endif
+#if ENABLE_FEATURE_COMMAND_TAB_COMPLETION
+	my_uid = getuid();
+	my_gid = getgid();
+#endif
 	/* Print out the command prompt */
 	parse_prompt(prompt);
 
@@ -1746,8 +1730,11 @@
 #if ENABLE_FEATURE_SH_FANCY_PROMPT
 	free((char*)cmdedit_prompt);
 #endif
-	/* restore initial_settings and SIGWINCH handler */
-	cmdedit_reset_term();
+	/* restore initial_settings */
+	setTermSettings(STDIN_FILENO, (void *) &initial_settings);
+	/* restore SIGWINCH handler */
+	signal(SIGWINCH, previous_SIGWINCH_handler);
+	fflush(stdout);
 	return command_len;
 }
 




More information about the busybox-cvs mailing list