Chapter 10. Interprocess Communication: Itâs good to talk
Creating processes is just half the story.
What if you want to control the process once itâs running? What if you want to send it data? Or read its output? Interprocess communication lets processes work together to get the job done. Weâll show you how to multiply the power of your code by letting it talk to other programs on your system.
Redirecting input and output
When you run programs from the command line, you can
redirect the Standard Output to a file using the >
operator:
The Standard Output is one of the three default data streams. A data stream is exactly what it sounds like: a stream of data that goes into, or comes out of, a process. There are data streams for the Standard Input, Output, and Error, and there are also data streams for other things, like files or network connections. When you redirect the output of a process, you change where the data is sent. So, instead of the Standard Output sending data to the screen, you can make it send the data to a file.
Redirection is really useful on the command line, but is there a way of making a process redirect itself?
A look inside a typical process
Every process will contain the program itâs running, as well as space for stack and heap data. But it will also ...
Get Head First C now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.