Index: app/plug-in/gimpplugin.c
===================================================================
RCS file: /cvs/gnome/gimp/app/plug-in/gimpplugin.c,v
retrieving revision 1.271
diff -u -p -r1.271 gimpplugin.c
--- app/plug-in/gimpplugin.c	20 Sep 2006 10:31:22 -0000	1.271
+++ app/plug-in/gimpplugin.c	26 Sep 2006 19:23:10 -0000
@@ -408,22 +408,43 @@ gimp_plug_in_close (GimpPlugIn *plug_in,
     {
 #ifndef G_OS_WIN32
       gint status;
+      gboolean dead = FALSE;
 #endif
 
       /*  Ask the filter to exit gracefully  */
       if (kill_it)
         {
+          gint i;
+
           gp_quit_write (plug_in->my_write, plug_in);
 
-          /*  give the plug-in some time (10 ms)  */
-          g_usleep (10000);
+          /*  give the plug-in some time to do sepukku with honor
+           *  (up to 1 sec, but exit the loop early if it dies early)
+           */
+
+          for (i = 0; i < 10; i++)
+            {
+#ifndef G_OS_WIN32
+              if (waitpid (plug_in->pid, &status, WNOHANG) > 0)
+#else
+              /* Someone do the Win32 bit, or it'll just hang here
+               * for a full second */
+              if (FALSE)
+#endif
+                {
+                  dead = TRUE;
+                  break;
+                }
+
+              g_usleep (G_USEC_PER_SEC / 10);
+            }
         }
 
       /* If necessary, kill the filter. */
 
 #ifndef G_OS_WIN32
 
-      if (kill_it)
+      if (kill_it && (! dead))
         {
           if (plug_in->manager->gimp->be_verbose)
             g_print (_("Terminating plug-in: '%s'\n"),
@@ -445,7 +466,7 @@ gimp_plug_in_close (GimpPlugIn *plug_in,
 
 #else /* G_OS_WIN32 */
 
-      if (kill_it)
+      if (kill_it && (! dead))
         {
           /* Trying to avoid TerminateProcess (does mostly work).
            * Otherwise some of our needed DLLs may get into an
