]> code.delx.au - gnu-emacs/blobdiff - lisp/epg.el
Fix timing problem of Bug#2412.
[gnu-emacs] / lisp / epg.el
index 7ad0d34b4b0ac757ed4683baa4e70d4880654130..3c80ef9db7741a06d722ee01e9dad7b273b6c3c0 100644 (file)
@@ -1,6 +1,6 @@
 ;;; epg.el --- the EasyPG Library
 ;; Copyright (C) 1999, 2000, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+;;   2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
 
 ;; Author: Daiki Ueno <ueno@unixuser.org>
 ;; Keywords: PGP, GnuPG
@@ -1168,12 +1168,15 @@ This function is for internal use only."
     (setq epg-pending-status-list status-list)
     (while (and (eq (process-status (epg-context-process context)) 'run)
                epg-pending-status-list)
-      (accept-process-output (epg-context-process context) 1))))
+      (accept-process-output (epg-context-process context) 1))
+    (if epg-pending-status-list
+       (epg-context-set-result-for context 'error 'exit))))
 
 (defun epg-wait-for-completion (context)
   "Wait until the `epg-gpg-program' process completes."
   (while (eq (process-status (epg-context-process context)) 'run)
-    (accept-process-output (epg-context-process context) 1)))
+    (accept-process-output (epg-context-process context) 1))
+  (sleep-for 0.1))
 
 (defun epg-reset (context)
   "Reset the CONTEXT."
@@ -2013,8 +2016,12 @@ If you are unsure, use synchronous version of this function
            (process-send-eof (epg-context-process context))))
     ;; Normal (or cleartext) signature.
     (if (epg-data-file signature)
-       (epg--start context (list "--" (epg-data-file signature)))
-      (epg--start context '("-"))
+       (epg--start context (if (eq (epg-context-protocol context) 'CMS)
+                               (list "--verify" "--" (epg-data-file signature))
+                             (list "--" (epg-data-file signature))))
+      (epg--start context (if (eq (epg-context-protocol context) 'CMS)
+                             '("--verify" "-")
+                           '("-")))
       (if (eq (process-status (epg-context-process context)) 'run)
          (process-send-string (epg-context-process context)
                               (epg-data-string signature)))