--- vte/ChangeLog	2007-10-22 17:39:20.000000000 +0530
+++ vte-new/ChangeLog	2007-10-22 18:47:35.000000000 +0530
@@ -1,3 +1,18 @@
+2007-10-22  Rajan Singh   <singh.rajan@wipro.com>
+
+	Makes gnome-terminal wait for pututxline to finish updation of the
+	utmpx database before closing the master fd.
+	Fixes #488960
+
+	* src/pty.c:_vte_pty_close () Waits for gnome_pty_helper to write to
+	the pipe.
+	* gnome-pty-helper/gnome-pty.h : Added new opcode GNOME_PTY_REMOVE_PTY
+	which is written by gnome-pty-helper to the pipe when pututxline is
+	done.
+	* gnome-pty-helper/gnome-pty-helper.c: main () Modified switch case. 
+	* gnome-pty-helper/gnome-utmp.c:write_logout_record () Writing opcode
+	to the pipe once pututxline is finished updating.
+
 2007-10-11  Chris Wilson  <chris@chris-wilson.co.uk>
 
 	Bug 439384 – gnome-terminal on feisty crashes when giving wrong locale environment
--- vte/src/pty.c	2007-10-22 17:39:05.000000000 +0530
+++ vte-new/src/pty.c	2007-10-22 17:50:12.000000000 +0530
@@ -1067,6 +1067,7 @@ _vte_pty_close(int pty)
 #ifdef VTE_USE_GNOME_PTY_HELPER
 	gpointer tag;
 	GnomePtyOps ops;
+	int vt;
 	if (_vte_pty_helper_map != NULL) {
 		if (g_tree_lookup(_vte_pty_helper_map, GINT_TO_POINTER(pty))) {
 			/* Signal the helper that it needs to close its
@@ -1082,6 +1083,8 @@ _vte_pty_close(int pty)
 				    &tag, sizeof(tag)) != sizeof(tag)) {
 				return;
 			}
+			read(_vte_pty_helper_tunnel,&vt,sizeof(vt));
+
 			/* Remove the item from the map. */
 			g_tree_remove(_vte_pty_helper_map,
 				      GINT_TO_POINTER(pty));
--- vte/gnome-pty-helper/gnome-pty.h	2007-10-22 17:39:06.000000000 +0530
+++ vte-new/gnome-pty-helper/gnome-pty.h	2007-10-22 17:50:12.000000000 +0530
@@ -11,7 +11,8 @@ typedef enum {
 	GNOME_PTY_OPEN_PTY_LASTLOGWTMP,
 	GNOME_PTY_OPEN_NO_DB_UPDATE,
 	GNOME_PTY_RESET_TO_DEFAULTS,
-	GNOME_PTY_CLOSE_PTY
+	GNOME_PTY_CLOSE_PTY,
+	GNOME_PTY_REMOVE_PTY
 } GnomePtyOps;
 
 void *update_dbs         (int utmp, int wtmp, int lastlog, char *login_name, char *display_name, char *term_name);
--- vte/gnome-pty-helper/gnome-pty-helper.c	2007-10-22 17:39:06.000000000 +0530
+++ vte-new/gnome-pty-helper/gnome-pty-helper.c	2007-10-22 17:50:12.000000000 +0530
@@ -763,6 +763,9 @@ main (int argc, char *argv [])
 			}
 			close_pty_pair (tag);
 			break;
+
+		case GNOME_PTY_REMOVE_PTY:
+			break;
 		}
 
 	}
--- vte/gnome-pty-helper/gnome-utmp.c	2007-10-22 17:39:06.000000000 +0530
+++ vte-new/gnome-pty-helper/gnome-utmp.c	2007-10-22 17:50:12.000000000 +0530
@@ -234,6 +234,7 @@ write_logout_record (char *login_name, v
 {
 	UTMP put, *ut = data;
 	struct timeval tv;
+	GnomePtyOps ops;
 
 	memset (&put, 0, sizeof(UTMP));
 
@@ -261,7 +262,11 @@ write_logout_record (char *login_name, v
 #endif
 
 	if (utmp)
-		update_utmp (&put);
+		{
+			update_utmp (&put);
+			ops = GNOME_PTY_REMOVE_PTY;
+			write (STDIN_FILENO,&ops,sizeof(ops));
+		}
 
 	if (wtmp)
 		update_wtmp (WTMP_OUTPUT_FILENAME, &put);
