(trunk libT) #3764 "script-torrent-done shouldn't block libtransmission" -- handle...
authorCharles Kerr <charles@transmissionbt.com>
Wed, 15 Dec 2010 15:35:06 +0000 (15:35 +0000)
committerCharles Kerr <charles@transmissionbt.com>
Wed, 15 Dec 2010 15:35:06 +0000 (15:35 +0000)
libtransmission/torrent.c

index fe94c403605feee94672d4b4506f9aeed7731a38..d4245967977a269841b3af319d56824d098754aa 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <sys/types.h> /* stat */
 #include <sys/stat.h> /* stat */
+#include <sys/wait.h> /* wait() */
 #include <unistd.h> /* stat */
 #include <dirent.h>
 
@@ -1849,6 +1850,12 @@ tr_torrentClearIdleLimitHitCallback( tr_torrent * torrent )
     tr_torrentSetIdleLimitHitCallback( torrent, NULL, NULL );
 }
 
+static void
+onSigCHLD( int i UNUSED )
+{
+    waitpid( -1, 0, WNOHANG );
+}
+
 static void
 torrentCallScript( const tr_torrent * tor, const char * script )
 {
@@ -1873,6 +1880,7 @@ torrentCallScript( const tr_torrent * tor, const char * script )
             NULL };
 
         tr_torinf( tor, "Calling script \"%s\"", script ); 
+        signal( SIGCHLD, onSigCHLD );
 
         if( !fork( ) )
         {