README.claws
authorMelvin Hadasht <melvin.hadasht@free.fr>
Mon, 10 Jun 2002 19:55:10 +0000 (19:55 +0000)
committerMelvin Hadasht <melvin.hadasht@free.fr>
Mon, 10 Jun 2002 19:55:10 +0000 (19:55 +0000)
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.

ChangeLog.claws
README.claws
configure.in
src/prefs_actions.c

index a5a313b..ddcac41 100644 (file)
@@ -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.
 
index 506107a..f248f1b 100644 (file)
@@ -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
 ----------
index 1b64e70..72f1b06 100644 (file)
@@ -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
index 574f3d9..1dfc699 100644 (file)
@@ -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;