Using spawn() to run a command, and communicating with it

Using .exec() is simple, but you are limited to small-sized outputs, and you cannot also get a partial answer: let's see more about this. Imagine you are preparing a large file to be sent to a client. If you were to read that file with .exec(), you wouldn't be able to start sending the file contents to a client until you had read all the file. However, if the file were too large, that would not only imply a delay, but also the possibility of a crash. Using .spawn() gives you an interesting addition: the possibility of using streams to communicate, in a bidirectional way, with the spawned process.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.21.76.0