diff src/gtkspell.c @ 1496:d33bf6548543

[gaim-migrate @ 1506] hrm. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Thu, 22 Feb 2001 00:42:55 +0000
parents 7f7857c5036e
children 60b3fd819cce
line wrap: on
line diff
--- a/src/gtkspell.c	Wed Feb 21 19:22:50 2001 +0000
+++ b/src/gtkspell.c	Thu Feb 22 00:42:55 2001 +0000
@@ -44,7 +44,7 @@
  * all ispell-related variables can be static.  
  */
 static pid_t spell_pid = -1;
-static int fd_write[2], fd_read[2];
+static int fd_write[2] = {0}, fd_read[2] = {0};
 static int signal_set_up = 0;
 
 /* FIXME? */
@@ -112,6 +112,9 @@
 void gtkspell_stop() {
 	if (gtkspell_running()) {
 		kill(spell_pid, SIGHUP); 
+		spell_pid = 0;
+		close(fd_read[0]);
+		close(fd_write[1]);
 	}
 }
 
@@ -139,11 +142,16 @@
 		return -1;
 	} else if (spell_pid == 0) {
 		dup2(fd_write[0], 0);
+		close(fd_write[0]);
+		close(fd_write[1]);
+
 		dup2(fd_read[1], 1);
-		dup2(fd_error[1], 2);
 		close(fd_read[0]);
+		close(fd_read[1]);
+
+		dup2(fd_error[1], 2);
 		close(fd_error[0]);
-		close(fd_write[1]);
+		close(fd_error[1]);
 
 		if (path == NULL) {
 			if (execvp(args[0], args) < 0) 
@@ -155,7 +163,7 @@
 		/* if we get here, we failed.
 		 * send some text on the pipe to indicate status.
 		 */
-		write(fd_read[1], "!", 1);
+		write(0, "!", 1); /* stdout _is_ the pipe. */
 
 		_exit(0);
 	} else {
@@ -167,11 +175,15 @@
 		fd_set rfds;
 		struct timeval tv;
 		
+		close(fd_write[0]);
+		close(fd_read[1]);
+
 		FD_ZERO(&rfds);
 		FD_SET(fd_error[0], &rfds);
 		FD_SET(fd_read[0], &rfds);
 		tv.tv_sec = 2;
 		tv.tv_usec = 0;
+
 		if (select(MAX(fd_error[0], fd_read[0])+1, 
 					&rfds, NULL, NULL, &tv) < 0) {
 			/* FIXME: is this needed? */
@@ -186,6 +198,10 @@
 			return -1;
 		}
 
+		/* we're done with stderr, now. */
+		close(fd_error[0]);
+		close(fd_error[1]);
+
 		/* otherwise, fd_read[0] is set. */
 		readline(buf);
 
@@ -416,6 +432,7 @@
 	}
 
 	gtk_editable_set_position(GTK_EDITABLE(gtktext), origpos);
+	gtk_editable_select_region(GTK_EDITABLE(gtktext), origpos, origpos);
 }
 
 static void entry_delete_cb(GtkText *gtktext,