سؤال

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