Last active
April 4, 2018 11:49
-
-
Save mykeels/ed062137bab265c15dbc00aa9eedf643 to your computer and use it in GitHub Desktop.
A simple example showing a Node program invoking the `ls` child process in a unix environment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (() => { | |
| const { spawn } = require('child_process'); | |
| const ls = spawn('ls', ['-lh', '/usr']); | |
| ls.stdout.on('data', (data) => { | |
| console.log(`stdout: ${data}`); | |
| }); | |
| ls.stderr.on('data', (data) => { | |
| console.log(`stderr: ${data}`); | |
| }); | |
| ls.on('close', (code) => { | |
| console.log(`child process exited with code ${code}`); | |
| }); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment