summaryrefslogtreecommitdiffstats
path: root/filter.c
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2018-09-17 19:40:22 -0700
committerKevin McCarthy <kevin@8t8.us>2018-09-17 19:56:01 -0700
commit4350694b55f676af23365ce14814c57032824ae9 (patch)
tree8729c66d6f1898c84d727d814a70814dfb747c8d /filter.c
parent668b76f29b62ac7fe35a8cd8e0dac98ebdf5d251 (diff)
Send imap keepalives for interactive filters.
When viewing attachments externally with a (non-copiousoutput) mailcap entry missing %s, the command is invoked as a filter, with the attachment piped into stdin. However, unlike a filter, the user interacts with the command, instead of just displaying the output in the pager. Just as with the mutt_system() command, Mutt needs to send imap keepalives to keep those connections from closing during the potentially extended invocation. Thanks to John Hawkinson for the bug report, and his suggested patch, which this commit is based upon.
Diffstat (limited to 'filter.c')
-rw-r--r--filter.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/filter.c b/filter.c
index 331d5425..59d1e09c 100644
--- a/filter.c
+++ b/filter.c
@@ -22,6 +22,9 @@
#include "mutt.h"
#include "mutt_curses.h"
+#ifdef USE_IMAP
+# include "imap.h"
+#endif
#include <unistd.h>
#include <stdlib.h>
@@ -189,3 +192,26 @@ int mutt_wait_filter (pid_t pid)
return rc;
}
+
+/*
+ * This is used for filters that are actually interactive commands
+ * with input piped in: e.g. in mutt_view_attachment(), a mailcap
+ * entry without copiousoutput _and_ without a %s.
+ *
+ * For those cases, we treat it like a blocking system command, and
+ * poll IMAP to keep connections open.
+ */
+int mutt_wait_interactive_filter (pid_t pid)
+{
+ int rc;
+
+#ifndef USE_IMAP
+ waitpid (pid, &rc, 0);
+#else
+ rc = imap_wait_keepalive (pid);
+#endif
+ mutt_unblock_signals_system (1);
+ rc = WIFEXITED (rc) ? WEXITSTATUS (rc) : -1;
+
+ return rc;
+}