Fix issue when using sudo that spawn sometimes will result in error
This commit is contained in:
parent
e69c735d64
commit
c5cbde1a3c
6
index.js
6
index.js
@ -73,8 +73,10 @@ function initTools(callback) {
|
||||
*/
|
||||
function scanNetworks(callback, useSudo) {
|
||||
const cmd = scanner.cmdLine.split(" ");
|
||||
const args = cmd.slice(1);
|
||||
const child = spawn((useSudo ? "sudo " : "" ) + cmd[0], args, { stdio: ['ignore', 'pipe', 'pipe'], detached: true });
|
||||
let args = cmd.slice(1);
|
||||
if(useSudo)
|
||||
args.unshift(cmd[0]);
|
||||
const child = spawn(useSudo ? "sudo" : cmd[0], args, { stdio: ['ignore', 'pipe', 'pipe'], detached: true });
|
||||
|
||||
child.on("error", (err) => callback(err, null) );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user