I am creating a process from a javascript. Is there any way to know when the process execution has been completed?

In win32 we can wait of the process handle using waitforsingleobject and know when the process execution is completed. I am looking for something similar in javascript.

Following is the code snippet

var retValue = process.Create(shellCmd);

Here I need to know when the process has completed its execution.

有帮助吗?

解决方案

You need to use the Child Process module.

var spawn = require('child_process').spawn;
var dir   = spawn('dir', []);

dir.on('close', function (code) {
  console.log('child process exited with code ' + code);
});
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top