Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

check if child_process has ended in node.js?

I am creating a cakefile using node.js and want to know if a child_process has ended before moving on the next one.

{exec} = require 'child_process'
 exec 'casperjs test.js', (err, stdout, stderr) ->
        err && throw err
        log stdout
        if //exec has finished
          log "finished executing"
like image 861
unknown Avatar asked Feb 19 '23 13:02

unknown


1 Answers

When the callback of exec is called, the process has already been terminated. There's no need to add an additional check.

For spawn, you can bind an exit event listener.

like image 52
Rob W Avatar answered Feb 21 '23 01:02

Rob W