From: Melvin Hadasht Date: Mon, 10 Jun 2002 19:55:10 +0000 (+0000) Subject: README.claws X-Git-Tag: rel_0_7_7~20 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=237631b4a99302b44b7295e8ba1388a89a3198b0 README.claws Added a hint to ac/README in cvs instructions. src/prefs_actions.c Made it possible to use a more elaborate command line for asynchronous actions, too. --- diff --git a/ChangeLog.claws b/ChangeLog.claws index a5a313beb..ddcac4188 100644 --- a/ChangeLog.claws +++ b/ChangeLog.claws @@ -1,8 +1,17 @@ +2002-06-10 [melvin] 0.7.6claws36 + + * README.claws + Added a hint to ac/README in cvs instructions. + + * src/prefs_actions.c + Made it possible to use a more elaborate command line + for asynchronous actions, too. + 2002-06-10 [melvin] 0.7.6claws35 * src/prefs_actions.c - Make it possible to use a more elaborate command line - (e.g. |foo|bar|cat>there;echo Done|) + Made it possible to use a more elaborate command line + (e.g. |foo|bar|cat>there;echo Done|). Corrected error message when calling %f, %F and %p commands from the compose window. diff --git a/README.claws b/README.claws index 506107ac7..f248f1bd8 100644 --- a/README.claws +++ b/README.claws @@ -508,7 +508,7 @@ sourceforge project page. make install [as root] You will need a full set of development tools installed to be able to run - autogen.sh. + autogen.sh. See also ac/README. 7. History ---------- diff --git a/configure.in b/configure.in index 1b64e7036..72f1b06a9 100644 --- a/configure.in +++ b/configure.in @@ -8,7 +8,7 @@ MINOR_VERSION=7 MICRO_VERSION=6 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=claws35 +EXTRA_VERSION=claws36 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION dnl set $target diff --git a/src/prefs_actions.c b/src/prefs_actions.c index 574f3d935..1dfc6995b 100644 --- a/src/prefs_actions.c +++ b/src/prefs_actions.c @@ -1245,52 +1245,68 @@ ChildInfo *fork_child(gchar *cmd, gchar *cmdline[4]; gint start, end, is_selection; gchar *selection; - pid_t pid_c, pid_gc; + pid_t pid, gch_pid; ChildInfo *child_info; + gint sync; - if (action_type & ACTION_ASYNC) { - execute_command_line(cmd, TRUE); - return NULL; /* Asynchronous command */ - } + sync = !(action_type & ACTION_ASYNC); - if (pipe(chld_in) || pipe(chld_out) || pipe(chld_err) || - pipe(chld_status)) { - alertpanel_error(_("Command could not started. Pipe creation" - " failed.\n%s"), g_strerror(errno)); - return NULL; /* Pipe error */ - } + chld_in[0] = chld_in[1] = chld_out[0] = chld_out[1] = chld_err[0] + = chld_err[1] = chld_status[0] = chld_status[1] = -1; + if (sync) + if (pipe(chld_status) || pipe(chld_in) || pipe(chld_out) + || pipe(chld_err)) { + alertpanel_error(_("Command could not started. " + "Pipe creation failed.\n%s"), + g_strerror(errno)); + /* Closing fd = -1 fails silently */ + close(chld_in[0]); + close(chld_in[1]); + close(chld_out[0]); + close(chld_out[1]); + close(chld_err[0]); + close(chld_err[1]); + close(chld_status[0]); + close(chld_status[1]); + return NULL; /* Pipe error */ + } + debug_print(_("Forking child and grandchild.\n")); - pid_c = fork(); - if (pid_c == (pid_t) 0) {/* Child */ + pid = fork(); + if (pid == (pid_t) 0) {/* Child */ if (setpgid(0, 0)) perror("setpgid"); close(ConnectionNumber(gdk_display)); - pid_gc = fork(); + gch_pid = fork(); - if (pid_gc == 0) { + if (gch_pid == 0) { if (setpgid(0, getppid())) perror("setpgid"); - if (action_type & - (ACTION_PIPE_IN | ACTION_OPEN_IN | ACTION_HIDE_IN)) { - close(fileno(stdin)); - dup (chld_in[0]); + if (sync) { + if (action_type & + (ACTION_PIPE_IN | + ACTION_OPEN_IN | + ACTION_HIDE_IN)) { + close(fileno(stdin)); + dup (chld_in[0]); + } + close(chld_in[0]); + close(chld_in[1]); + + close(fileno(stdout)); + dup (chld_out[1]); + close(chld_out[0]); + close(chld_out[1]); + + close(fileno(stderr)); + dup (chld_err[1]); + close(chld_err[0]); + close(chld_err[1]); } - close(chld_in[0]); - close(chld_in[1]); - - close(fileno(stdout)); - dup (chld_out[1]); - close(chld_out[0]); - close(chld_out[1]); - - close(fileno(stderr)); - dup (chld_err[1]); - close(chld_err[0]); - close(chld_err[1]); cmdline[0] = "sh"; cmdline[1] = "-c"; @@ -1301,27 +1317,32 @@ ChildInfo *fork_child(gchar *cmd, perror("execvp"); _exit(1); - } else if (pid_gc < (pid_t) 0) {/* Fork erro */ - write(chld_status[1], "1\n", 2); + } else if (gch_pid < (pid_t) 0) {/* Fork error */ + if (sync) + write(chld_status[1], "1\n", 2); perror("fork"); _exit(1); } else {/* Child */ - close(chld_in[0]); - close(chld_in[1]); - close(chld_out[0]); - close(chld_out[1]); - close(chld_err[0]); - close(chld_err[1]); + if (sync) { + close(chld_in[0]); + close(chld_in[1]); + close(chld_out[0]); + close(chld_out[1]); + close(chld_err[0]); + close(chld_err[1]); + close(chld_status[0]); + } - close(chld_status[0]); debug_print(_("Child: Waiting for grandchild\n")); - waitpid(pid_gc, NULL, 0); + waitpid(gch_pid, NULL, 0); debug_print(_("Child: grandchild ended\n")); - write(chld_status[1], "0\n", 2); - close(chld_status[1]); + if (sync) { + write(chld_status[1], "0\n", 2); + close(chld_status[1]); + } _exit(0); } - } else if (pid_c < (pid_t) 0) {/* Fork error */ + } else if (pid < (pid_t) 0) {/* Fork error */ alertpanel_error(_("Could not fork to execute the following " "command:\n%s\n%s"), cmd, g_strerror(errno)); @@ -1329,6 +1350,9 @@ ChildInfo *fork_child(gchar *cmd, } /* Parent */ + if (!sync) + return NULL; + close(chld_in[0]); if (!(action_type & (ACTION_PIPE_IN | ACTION_OPEN_IN | ACTION_HIDE_IN))) close(chld_in[1]); @@ -1340,7 +1364,7 @@ ChildInfo *fork_child(gchar *cmd, child_info->children = children; - child_info->pid = pid_c; + child_info->pid = pid; child_info->cmd = g_strdup(cmd); child_info->type = action_type; child_info->new_out = FALSE;