Child processes that are long-running and require data input and output should be created with the spawn function. The exec function is made for these types of child processes. In this video, learn how to spawn a child process. Once spawned, learn how to communicate with the child process through standard input and standard output.
- In the last lesson, we used the execute function … to execute external system commands. … In this lesson, we're going to take a look … at the spawn function. … Now execute is designed to handle synchronous processes. … These are processes that run and close … and maybe spit back some data as … a one time event. … However execute is not meant to handle … a synchronous processes. … This could mean long running processes … or processes that are waiting for input … or anything that remains open. … Consider the app that we built back … in chapter four. … The question app. … I have it here within this start folder. … So if I type node questions we are asked three questions. … What is your name? … Alex. … Where do you live? … Tahoe. … And notice this application is running. … It's asynchronous. … It's waiting for me to add some input … before it continues. … And once I answer the three questions, … those questions are displayed back to us … in the terminal. … So the process collects answers …
- What is Node.js?
- Installing Node.js
- The global object
- Importing the core modules
- Creating custom events with the EventEmitter
- Reading, writing, and removing files
- Working with file streams
- Creating child processes with the exec and spawn functions
Skill Level Intermediate
Node.js: Real-Time Web with Socket.IOwith Emmanuel Henri1h 24m Intermediate
1. What Is Node.js?
2. Set Up Your Environnment
3. Node Globals
4. Node Modules
5. File System Basics
6. Files and Streams
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.