[英]child process in node is not getting the correct PID id
while i trying to spawn a batch file am not getting the correct PID
of that child proces
s. 当我尝试生成批处理文件时,没有获得该
child proces
的正确PID
。
when i tried to kill the PID
of the child process ,the running process is not stoping and it stops another cmd
当我尝试杀死子进程的
PID
时,正在运行的进程没有停止,并且停止了另一个cmd
i dont know how it is happening. 我不知道这是怎么回事。
in my batch file am doing to open another cmd
and change the directry to C:\\AppiumForWindows-1.0.0\\Appium\\node_modules\\appium\\bin
and run a node
process node appium
在我的批处理文件中,正在打开另一个
cmd
,并将目录更改为C:\\AppiumForWindows-1.0.0\\Appium\\node_modules\\appium\\bin
并运行node
进程node appium
.i want to execute that node
process in seperate cmd
(While spawning that batch
file it will execute with the same script .i don't need that.)that's what i use separate cmd. .i我想在单独的
cmd
执行该node
进程(尽管生成该batch
文件时,它将使用相同的脚本执行。我不需要那个。)这就是我使用单独的cmd的原因。
Am confusing due this reason am not getting the correct PID
of that process?i don't know... 由于这个原因使我感到困惑,因为没有获得该进程的正确
PID
?我不知道...
var startappium = function (dev, callback) {
var ports = {};
var execCmd = __dirname+"//Start.bat";
var args = ['1000'];
var start = spawn(execCmd, args);
console.log("pid id----------------------",start.pid)
var pid =start.pid
start.stdout.on('data', function (d) {
setTimeout(function() {
start .kill() // it does not kill the process
},5000);
console.log(d.toString())
return callback(null, ports);
});
start.stderr.on('data', function (ta) {
return callback(null, ta);
});
start.on('close', function (code) {
console.log("close: ",code)
});
}
startappium()
Start.bat
file Start.bat
文件
@echo off
start cmd /k " call "C:\Program Files\nodejs\nodevars.bat" & pushd C:\AppiumForWindows-1.0.0\Appium\node_modules\appium\bin && node appium -p %1 --chromedriver-port %2"
pause
while running tasklist
it shows cms with several PID
's and i tried to kill one by one and killed that running batch
file process in one PID
. 在运行
tasklist
它显示具有多个PID
的cms,我试图一一杀死并在一个PID
杀死正在运行的batch
文件进程。
PID
getting from the child process id not killing the batch process running. 从子进程ID获取
PID
不会终止正在运行的批处理进程。 Please suggest a solution for this. 请为此提出解决方案。
You can't kill a pid as it's an integer. 您无法杀死pid,因为它是整数。 You want to kill the spawned process :
您想杀死生成的进程 :
start.kill();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.