Skip to content
This repository has been archived by the owner on Sep 23, 2021. It is now read-only.

How to detect if command run terminates #37

Closed
dgramop opened this issue Jan 7, 2017 · 1 comment
Closed

How to detect if command run terminates #37

dgramop opened this issue Jan 7, 2017 · 1 comment

Comments

@dgramop
Copy link

dgramop commented Jan 7, 2017

Hi!
Just curious as to how I would detect if the command terminates. I tried setting the exec to a variable and doing variable.on(....) as I would to a normal async child process.

Is there any way I can do that?

Does this run the command asynchronously?

@jorangreef
Copy link
Owner

Thanks @BrainyBrian

To confirm, your command will be run asynchronously in another process.

Your callback will be called as soon as your command terminates:

sudo.exec('echo hello', options,
  function(error, stdout, stderr) {
    console.log('command terminated');
  }
);

sudo-prompt exec() is different to that of child-process since it needs to deal with permissions issues on different platforms. It does not return a child process instance.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants