summaryrefslogtreecommitdiffstats
path: root/handler.c
diff options
context:
space:
mode:
authorThomas Roessler <roessler@does-not-exist.org>1998-10-05 20:37:08 +0000
committerThomas Roessler <roessler@does-not-exist.org>1998-10-05 20:37:08 +0000
commit19fbdcf0bff0e1a81debe644c8a23576222eb9d1 (patch)
tree383f44e1b8a7fbff04dfce34c802156054be3efc /handler.c
parent04a38530367ac964b340b402d7672aea415c32d0 (diff)
Avoid a hang due to blocking pipe writes in the auto view code.
Diffstat (limited to 'handler.c')
-rw-r--r--handler.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/handler.c b/handler.c
index b6c48ca0..8e045a47 100644
--- a/handler.c
+++ b/handler.c
@@ -1078,25 +1078,29 @@ void autoview_handler (BODY *a, STATE *s)
mutt_message(_("Invoking autoview command: %s"),command);
}
- if (piped)
+ if ((fpin = safe_fopen (tempfile, "w+")) == NULL)
{
- thepid = mutt_create_filter (command, &fpin, &fpout, &fperr);
- mutt_copy_bytes (s->fpin, fpin, a->length);
- fclose (fpin);
+ mutt_perror ("fopen");
+ rfc1524_free_entry (&entry);
+ return;
}
- else
- {
- if ((fpin = safe_fopen (tempfile, "w")) == NULL)
- {
- mutt_perror ("fopen");
- rfc1524_free_entry (&entry);
- return;
- }
+
+ mutt_copy_bytes (s->fpin, fpin, a->length);
- mutt_copy_bytes (s->fpin, fpin, a->length);
+ if(!piped)
+ {
fclose (fpin);
thepid = mutt_create_filter (command, NULL, &fpout, &fperr);
}
+ else
+ {
+ unlink(tempfile);
+ fflush(fpin);
+ rewind(fpin);
+ thepid = mutt_create_filter_fd (command, NULL, &fpout, &fperr,
+ dup(fileno(fpin)), -1, -1);
+ fclose(fpin);
+ }
if (s->prefix)
{
@@ -1147,7 +1151,9 @@ void autoview_handler (BODY *a, STATE *s)
fclose (fpout);
fclose (fperr);
mutt_wait_filter (thepid);
- mutt_unlink (tempfile);
+ if(!piped)
+ mutt_unlink (tempfile);
+
if (s->flags & M_DISPLAY)
mutt_clear_error ();
}