about summary refs log tree commit diff stats
path: root/about.c
diff options
context:
space:
mode:
authorJosh Rickmar <jrick@devio.us>2012-06-21 16:59:53 -0400
committerJosh Rickmar <jrick@devio.us>2012-06-28 15:21:30 -0400
commite9354ac12cb68dbc4f257da32c70076e1f731eb1 (patch)
treec4aba597752b6a0ae10c9c44af596499849eecaa /about.c
parent79d78050066abe7a69a32ab39b9f916a659df897 (diff)
downloadxombrero-e9354ac12cb68dbc4f257da32c70076e1f731eb1.tar.gz
Use glib's g_spawn_async() function instead of OS-specific fork/exec
or spawning functions.  Remove the SIGCHLD handling as that is no
longer required to stop zombie processes.
Diffstat (limited to 'about.c')
-rw-r--r--about.c39
1 files changed, 14 insertions, 25 deletions
diff --git a/about.c b/about.c
index f122817..9305fb6 100644
--- a/about.c
+++ b/about.c
@@ -730,7 +730,6 @@ search_engine_add(char *body, const char *name, const char *url, int select)
 void
 xtp_handle_ab(struct tab *t, uint8_t cmd, int arg)
 {
-	pid_t			pid;
 	char			config[PATH_MAX];
 	char			*cmdstr;
 	char			**sv;
@@ -741,30 +740,20 @@ xtp_handle_ab(struct tab *t, uint8_t cmd, int arg)
 			show_oops(t, "external_editor is unset");
 			break;
 		}
-		switch (pid = fork()) {
-		case -1:
-			/* no process created */
-			show_oops(t, "%s: could not fork process", __func__);
-			break;
-		case 0:
-			/* child */
-			snprintf(config, sizeof config, "%s" PS ".%s",
-			    pwd->pw_dir, XT_CONF_FILE);
-
-			sv = g_strsplit(external_editor, "<file>", -1);
-			cmdstr = g_strjoinv(config, sv);
-			g_strfreev(sv);
-
-			sv = g_strsplit_set(cmdstr, " \t", -1);
-
-			execvp(sv[0], sv);
-			g_strfreev(sv);
-			g_free(cmdstr);
-			_exit(0);
-		default:
-			/* parent */
-			break;
-		}
+
+		snprintf(config, sizeof config, "%s" PS ".%s", pwd->pw_dir,
+		    XT_CONF_FILE);
+		sv = g_strsplit(external_editor, "<file>", -1);
+		cmdstr = g_strjoinv(config, sv);
+		g_strfreev(sv);
+		sv = g_strsplit_set(cmdstr, " \t", -1);
+
+		if (!g_spawn_async(NULL, sv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL,
+		    NULL, NULL))
+			show_oops(t, "%s: could not spawn process", __func__);
+
+		g_strfreev(sv);
+		g_free(cmdstr);
 		break;
 	default:
 		show_oops(t, "%s, invalid about command", __func__);