node-rsync icon indicating copy to clipboard operation
node-rsync copied to clipboard

kill does not work

Open thisboyiscrazy opened this issue 8 years ago • 3 comments

Rsync = require('rsync');

cmd = new Rsync()
    .flags('avz')
    .source('src/')
    .destination('dst/');

c = cmd.execute(
    function(error,code,cmd) { console.log("Done"); },
    function(data) { console.log(data.toString()); },
    function(data) { console.log(data.toString()); },
);

setTimeout(function() {
    console.log("!!!!!!!Killing!!!!!!");
    c.kill();
},4000);

Should kill the sync after 4 seconds. It does not. rsync does seem to receive the signal.

thisboyiscrazy avatar Jun 13 '17 03:06 thisboyiscrazy

This seems to be debian only issue. But still it does not work as expected.

thisboyiscrazy avatar Jun 13 '17 12:06 thisboyiscrazy

On Debian, /bin/sh is linked to dash. Dash doesn't seem to support job control...the solution is to set the shell to /bin/bash:

var sync = new rsync()
  .executableShell('/bin/bash')
  .source(sourcepath)
  .destination(destpath);

mw-white avatar Jun 13 '17 15:06 mw-white

Just wondering, why are you using a shell instead of just calling rsync?

        cmdProc = spawn(this.executable(), this.args(),
                        { stdio: 'pipe', cwd: this._cwd, env: this._env });

seems to pass all test and work correctly on linux.

thisboyiscrazy avatar Jun 16 '17 17:06 thisboyiscrazy