diff --git a/libtransmission/torrent.c b/libtransmission/torrent.c index c4d49cf16..9ba64f040 100644 --- a/libtransmission/torrent.c +++ b/libtransmission/torrent.c @@ -12,7 +12,12 @@ #include /* stat */ #include /* stat */ -#include /* wait() */ +#ifndef WIN32 + #include /* wait() */ +#else + #include + #define waitpid(pid, status, options) _cwait(status, pid, WAIT_CHILD) +#endif #include /* stat */ #include @@ -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] );