2006-10-07 [colin] 2.5.3cvs20
authorColin Leroy <colin@colino.net>
Sat, 7 Oct 2006 19:54:35 +0000 (19:54 +0000)
committerColin Leroy <colin@colino.net>
Sat, 7 Oct 2006 19:54:35 +0000 (19:54 +0000)
* src/plugins/pgpcore/pgp_viewer.c
Kill gpg after 5 seconds wait

ChangeLog
PATCHSETS
configure.ac
src/plugins/pgpcore/pgp_viewer.c

index 1e57df8f842d50bd5bbf5b0d98043afc9fc4ecbf..9e84d78c1dd1f51771dc56cdd28f679d02ff361d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-10-07 [colin]     2.5.3cvs20
+
+       * src/plugins/pgpcore/pgp_viewer.c
+               Kill gpg after 5 seconds wait
+
 2006-10-07 [colin]     2.5.3cvs19
 
        * src/plugins/pgpcore/pgp_viewer.c
 2006-10-07 [colin]     2.5.3cvs19
 
        * src/plugins/pgpcore/pgp_viewer.c
index 9b5069025fb462a9db58c9c826431a723392a6a3..e713fe3ca4ef18d45bd439d3af40247c527c367e 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.1.2.28 -r 1.1.2.29 src/plugins/pgpcore/sgpgme.c;  ) > 2.5.3cvs17.patchset
 ( diff -u /dev/null src/plugins/pgpcore/pgp_viewer.c;  diff -u /dev/null src/plugins/pgpcore/pgp_viewer.h;  ) > 2.5.3cvs18.patchset
 ( cvs diff -u -r 1.1.2.1 -r 1.1.2.2 src/plugins/pgpcore/pgp_viewer.c;  cvs diff -u -r 1.1.2.1 -r 1.1.2.2 src/plugins/pgpcore/pgp_viewer.h;  ) > 2.5.3cvs19.patchset
 ( cvs diff -u -r 1.1.2.28 -r 1.1.2.29 src/plugins/pgpcore/sgpgme.c;  ) > 2.5.3cvs17.patchset
 ( diff -u /dev/null src/plugins/pgpcore/pgp_viewer.c;  diff -u /dev/null src/plugins/pgpcore/pgp_viewer.h;  ) > 2.5.3cvs18.patchset
 ( cvs diff -u -r 1.1.2.1 -r 1.1.2.2 src/plugins/pgpcore/pgp_viewer.c;  cvs diff -u -r 1.1.2.1 -r 1.1.2.2 src/plugins/pgpcore/pgp_viewer.h;  ) > 2.5.3cvs19.patchset
+( cvs diff -u -r 1.1.2.2 -r 1.1.2.3 src/plugins/pgpcore/pgp_viewer.c;  ) > 2.5.3cvs20.patchset
index 07e0bd1a59f8f20dcd4056231f3dc32d765086e9..483d4798c1f6a05bb9759fb0ba7e4e881d049b06 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=5
 MICRO_VERSION=3
 INTERFACE_AGE=0
 BINARY_AGE=0
 MICRO_VERSION=3
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=19
+EXTRA_VERSION=20
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index e9225282a7356ae0583f647821faf43acd5adc98..eb5f1167aaf0c8cb9d29384fa109accabcb742f0 100644 (file)
@@ -25,6 +25,8 @@
 #include <stddef.h>
 #include <glib.h>
 #include <glib/gi18n.h>
 #include <stddef.h>
 #include <glib.h>
 #include <glib/gi18n.h>
+#include <sys/types.h>
+#include <sys/wait.h>
 
 #include "version.h"
 #include "common/sylpheed.h"
 
 #include "version.h"
 #include "common/sylpheed.h"
@@ -119,8 +121,38 @@ static void pgpview_show_mime_part(TextView *textview, MimeInfo *partinfo)
 #ifndef G_OS_WIN32
                        gchar *cmd = g_strdup_printf("gpg --recv-keys %s", sig->fpr);
                        int res = 0;
 #ifndef G_OS_WIN32
                        gchar *cmd = g_strdup_printf("gpg --recv-keys %s", sig->fpr);
                        int res = 0;
+                       pid_t pid = 0;
                        GTK_EVENTS_FLUSH();
                        GTK_EVENTS_FLUSH();
-                       res = system(cmd);
+                       
+                       pid = fork();
+                       if (pid == -1) {
+                               res = -1;
+                       } else if (pid == 0) {
+                               /* son */
+                               res = system(cmd);
+                               _exit(res);
+                       } else {
+                               int status = 0;
+                               time_t start_wait = time(NULL);
+                               res = -1;
+                               do {
+                                       if (waitpid(pid, &status, WNOHANG) == 0 || !WIFEXITED(status)) {
+                                               usleep(200000);
+                                       } else {
+                                               res = WEXITSTATUS(status);
+                                               break;
+                                       }
+                                       if (time(NULL) - start_wait > 5) {
+                                               debug_print("SIGTERM'ing gpg\n");
+                                               kill(pid, SIGTERM);
+                                       }
+                                       if (time(NULL) - start_wait > 6) {
+                                               debug_print("SIGKILL'ing gpg\n");
+                                               kill(pid, SIGKILL);
+                                               break;
+                                       }
+                               } while(1);
+                       }
                        if (res == 0) {
                                TEXTVIEW_INSERT(_("   This key has been imported to your keyring.\n"));
                        } else {
                        if (res == 0) {
                                TEXTVIEW_INSERT(_("   This key has been imported to your keyring.\n"));
                        } else {