1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-20 02:03:15 +00:00

Updated xclip clipboard, to so xclip cleanup occurs if process exits before xclip timeout

This commit is contained in:
Bryan Roe
2020-06-08 14:40:00 -07:00
parent 628e44121a
commit e448456d9e
2 changed files with 47 additions and 36 deletions

File diff suppressed because one or more lines are too long

View File

@@ -316,9 +316,7 @@ function lin_xclip_copy(txt)
ret.child.promise = ret; ret.child.promise = ret;
ret.child.stderr.on('data', function (c) { console.log(c.toString()); }); ret.child.stderr.on('data', function (c) { console.log(c.toString()); });
ret.child.stdout.on('data', function (c) { console.log(c.toString()); }); ret.child.stdout.on('data', function (c) { console.log(c.toString()); });
ret.child.on('exit', function () ret.child._cleanup = function _cleanup(p)
{
xclipTable[this.promise._hashCode()] = setTimeout(function (p)
{ {
var ch = require('child_process').execFile('/bin/sh', ['sh']); var ch = require('child_process').execFile('/bin/sh', ['sh']);
ch.stdout.str = ''; ch.stdout.on('data', function (c) { this.str += c.toString(); }); 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(' }');
ch.stdin.write("}'\nexit\n"); ch.stdin.write("}'\nexit\n");
ch.waitExit(); ch.waitExit();
if(ch.stdout.str != '') if (ch.stdout.str != '')
{ {
process.kill(parseInt(ch.stdout.str), 'SIGKILL'); process.kill(parseInt(ch.stdout.str), 'SIGKILL');
} }
delete xclipTable[p._hashCode()]; delete xclipTable[p._hashCode()];
};
ret.child.on('exit', function ()
{
xclipTable[this.promise._hashCode()] = setTimeout(function (p)
{
p.child._cleanup(p);
}, 20000, this.promise); }, 20000, this.promise);
this.promise._res(); this.promise._res();
}); });
@@ -358,6 +362,13 @@ function lin_xclip_copy(txt)
{ {
this.end(); this.end();
}); });
ret.child.on('~', function ()
{
if (xclipTable[this.promise._hashCode()])
{
this._cleanup(this.promise);
}
});
return (ret); return (ret);
} }