finch/libgnt/gnttextview.c

changeset 18778
7cf5400593b8
parent 18604
2ff126dbae16
child 18791
12003d1b25bf
--- a/finch/libgnt/gnttextview.c	Fri Jul 13 16:05:30 2007 +0000
+++ b/finch/libgnt/gnttextview.c	Fri Jul 13 16:50:03 2007 +0000
@@ -26,6 +26,7 @@
 
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
 
 enum
 {
@@ -795,6 +796,13 @@
 	view->flags |= flag;
 }
 
+static void
+pager_end_cb(int status, gpointer data)
+{
+	unlink(data);
+	g_free(data);
+}
+
 static gboolean
 check_for_pager_cb(GntWidget *widget, const char *key, GntTextView *view)
 {
@@ -803,6 +811,7 @@
 	static char path[1024];
 	static int len = -1;
 	FILE *file;
+	gboolean ret;
 
 	if (combin == NULL) {
 		combin = gnt_key_translate(gnt_style_get_from_name("pager", "key"));
@@ -826,8 +835,11 @@
 	argv[0] = gnt_style_get_from_name("pager", "path");
 	argv[0] = argv[0] ? argv[0] : getenv("PAGER");
 	argv[0] = argv[0] ? argv[0] : "less";
-	argv[1] = path;
-	return gnt_giveup_console(NULL, argv, NULL, NULL, NULL, NULL);
+	argv[1] = g_strdup(path);
+	ret = gnt_giveup_console(NULL, argv, NULL, NULL, NULL, NULL, pager_end_cb, argv[1]);
+	if (!ret)
+		g_free(argv[1]);
+	return ret;
 }
 
 void gnt_text_view_attach_pager_widget(GntTextView *view, GntWidget *pager)

mercurial