Frage

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.

War es hilfreich?

Lösung

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);
});
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top