From e9354ac12cb68dbc4f257da32c70076e1f731eb1 Mon Sep 17 00:00:00 2001 From: Josh Rickmar Date: Thu, 21 Jun 2012 16:59:53 -0400 Subject: 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. --- about.c | 39 ++++++++++++++------------------------- 1 file changed, 14 insertions(+), 25 deletions(-) (limited to 'about.c') 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, "", -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, "", -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__); -- cgit 1.4.1-2-gfad0