1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 09:37:56 +00:00

(trunk libT) #3961 "Support for running scripts when a torrent finishes downloading on Windows" -- fixed. patch by rb07

The changes to torrentCallScript() weren't portable to Windows, so rb07 has provided a patch.
This commit is contained in:
Jordan Lee 2011-01-30 01:41:48 +00:00
parent 69d99f252f
commit e7f81543ec

View file

@ -12,7 +12,12 @@
#include <sys/types.h> /* stat */
#include <sys/stat.h> /* stat */
#include <sys/wait.h> /* wait() */
#ifndef WIN32
#include <sys/wait.h> /* wait() */
#else
#include <process.h>
#define waitpid(pid, status, options) _cwait(status, pid, WAIT_CHILD)
#endif
#include <unistd.h> /* stat */
#include <dirent.h>
@ -1941,7 +1946,7 @@ tr_torrentClearIdleLimitHitCallback( tr_torrent * torrent )
static void
onSigCHLD( int i UNUSED )
{
waitpid( -1, 0, WNOHANG );
waitpid( -1, NULL, WNOHANG );
}
static void
@ -1969,6 +1974,10 @@ torrentCallScript( const tr_torrent * tor, const char * script )
NULL };
tr_torinf( tor, "Calling script \"%s\"", script );
#ifdef WIN32
_spawnvpe( _P_NOWAIT, script, (const char*)cmd, env );
#else
signal( SIGCHLD, onSigCHLD );
if( !fork( ) )
@ -1976,6 +1985,7 @@ torrentCallScript( const tr_torrent * tor, const char * script )
execve( script, cmd, env );
_exit( 0 );
}
#endif
for( i=0; cmd[i]; ++i ) tr_free( cmd[i] );
for( i=0; env[i]; ++i ) tr_free( env[i] );