mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-16 00:03:45 +00:00
Updated xclip clipboard, to so xclip cleanup occurs if process exits before xclip timeout
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -316,9 +316,7 @@ function lin_xclip_copy(txt)
|
||||
ret.child.promise = ret;
|
||||
ret.child.stderr.on('data', function (c) { console.log(c.toString()); });
|
||||
ret.child.stdout.on('data', function (c) { console.log(c.toString()); });
|
||||
ret.child.on('exit', function ()
|
||||
{
|
||||
xclipTable[this.promise._hashCode()] = setTimeout(function (p)
|
||||
ret.child._cleanup = function _cleanup(p)
|
||||
{
|
||||
var ch = require('child_process').execFile('/bin/sh', ['sh']);
|
||||
ch.stdout.str = ''; ch.stdout.on('data', function (c) { this.str += c.toString(); });
|
||||
@@ -346,11 +344,17 @@ function lin_xclip_copy(txt)
|
||||
ch.stdin.write(' }');
|
||||
ch.stdin.write("}'\nexit\n");
|
||||
ch.waitExit();
|
||||
if(ch.stdout.str != '')
|
||||
if (ch.stdout.str != '')
|
||||
{
|
||||
process.kill(parseInt(ch.stdout.str), 'SIGKILL');
|
||||
}
|
||||
delete xclipTable[p._hashCode()];
|
||||
};
|
||||
ret.child.on('exit', function ()
|
||||
{
|
||||
xclipTable[this.promise._hashCode()] = setTimeout(function (p)
|
||||
{
|
||||
p.child._cleanup(p);
|
||||
}, 20000, this.promise);
|
||||
this.promise._res();
|
||||
});
|
||||
@@ -358,6 +362,13 @@ function lin_xclip_copy(txt)
|
||||
{
|
||||
this.end();
|
||||
});
|
||||
ret.child.on('~', function ()
|
||||
{
|
||||
if (xclipTable[this.promise._hashCode()])
|
||||
{
|
||||
this._cleanup(this.promise);
|
||||
}
|
||||
});
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user