Ticket #3961: torrent.c.diff

File torrent.c.diff, 1.2 KB (added by rb07, 11 years ago)

Adaptation to Windows.

  • libtransmission/torrent.c

     
    1212
    1313#include <sys/types.h> /* stat */
    1414#include <sys/stat.h> /* stat */
    15 #include <sys/wait.h> /* wait() */
     15#ifndef WIN32
     16 #include <sys/wait.h> /* wait() */
     17#else
     18 #include <process.h>
     19 #define waitpid(pid, status, options)  _cwait(status, pid, WAIT_CHILD)
     20#endif
    1621#include <unistd.h> /* stat */
    1722#include <dirent.h>
    1823
     
    19411946static void
    19421947onSigCHLD( int i UNUSED )
    19431948{
    1944     waitpid( -1, 0, WNOHANG );
     1949    waitpid( -1, NULL, WNOHANG );
    19451950}
    19461951
    19471952static void
     
    19691974            NULL };
    19701975
    19711976        tr_torinf( tor, "Calling script \"%s\"", script );
     1977#ifndef WIN32
    19721978        signal( SIGCHLD, onSigCHLD );
    19731979
    19741980        if( !fork( ) )
     
    19761982            execve( script, cmd, env );
    19771983            _exit( 0 );
    19781984        }
     1985#else
     1986/* #warning "Windows doesn't have SIGCHLD signal" */
     1987        _spawnvpe( _P_NOWAIT, script, (const char*)cmd, env );
     1988#endif
    19791989
    19801990        for( i=0; cmd[i]; ++i ) tr_free( cmd[i] );
    19811991        for( i=0; env[i]; ++i ) tr_free( env[i] );