128391ea2abe6a4464d696d19cf6a7b559d5c5b1
diff --git a/src/vte-private.h b/src/vte-private.h
index 7e88d28..77b105c 100644
--- a/src/vte-private.h
+++ b/src/vte-private.h
@@ -207,6 +207,7 @@ struct _VteTerminalPrivate {
 	gboolean pty_input_active;
 	GPid pty_pid;			/* pid of child using pty slave */
 	VteReaper *pty_reaper;
+        int child_exit_status;
 
 	/* Input data queues. */
 	const char *encoding;		/* the pty's encoding */
diff --git a/src/vte.c b/src/vte.c
index 0f2fce9..9749e5f 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -3163,6 +3163,7 @@ vte_terminal_catch_child_exited(VteReaper *reaper, int pid, int status,
 		_vte_buffer_clear(terminal->pvt->outgoing);
 
 		/* Tell observers what's happened. */
+                terminal->pvt->child_exit_status = status;
 		vte_terminal_emit_child_exited(terminal);
 	}
 }
@@ -12426,6 +12427,24 @@ vte_terminal_set_pty(VteTerminal *terminal, int pty_master)
        _vte_terminal_connect_pty_read(terminal);
 }
 
+/**
+ * vte_terminal_get_child_exit_status:
+ * @terminal: a #VteTerminal
+ *
+ * NOTE that this function may only be called from the signal handler of
+ * the "child-exited" signal.
+ * 
+ * Returns: the child's exit status
+ * 
+ * Since: 0.16.14
+ */
+int
+vte_terminal_get_child_exit_status(VteTerminal *terminal)
+{
+        g_return_val_if_fail(VTE_IS_TERMINAL(terminal), -1);
+        return terminal->pvt->child_exit_status;
+}
+
 /* We need this bit of glue to ensure that accessible objects will always
  * get signals. */
 void
diff --git a/src/vte.h b/src/vte.h
index cbc5188..ea8d262 100644
--- a/src/vte.h
+++ b/src/vte.h
@@ -414,6 +414,8 @@ glong vte_terminal_get_column_count(VteTerminal *terminal);
 const char *vte_terminal_get_window_title(VteTerminal *terminal);
 const char *vte_terminal_get_icon_title(VteTerminal *terminal);
 
+int vte_terminal_get_child_exit_status(VteTerminal *terminal);
+
 G_END_DECLS
 
 #endif
