Book Image

C++ Programming for Linux Systems

By : Desislav Andreev, Stanimir Lukanov
Book Image

C++ Programming for Linux Systems

By: Desislav Andreev, Stanimir Lukanov

Overview of this book

Around 35 million Linux and almost 2 billion Android users rely on C++ for everything from the simplest embedded and IoT devices to cloud services, supercomputing, and space exploration. To help you produce high-quality software, two industry experts have transformed their knowledge and experience into practical examples in system programming with C++ Programming for Linux Systems. In this book, you'll explore the latest C++20 features, while working on multiple specific use cases. You’ll get familiar with the coroutines and modern approaches in concurrent and multithreaded programming. You'll also learn to reshape your thinking when analyzing system behavior in Linux (POSIX) environments. Additionally, you'll discover advanced discussions and novel solutions for complex challenges, while approaching trivial system operations with a new outlook and learning to choose the best design for your particular case. You can use this workbook as an introduction to system programming and software design in Linux or any Unix-based environment. You’ll also find it useful as a guideline or a supplement to any C++ book. By the end of this book, you’ll have gained advanced knowledge and skills for working with Linux or any Unix-based environment.
Table of Contents (15 chapters)
Free Chapter
1
Part 1:Securing the Fundamentals
7
Part 2:Advanced Techniques for System Programming

IPC through anonymous pipes and named pipes

Before we even start working on this topic, let us ask you this. Have you ever done the following:

$ cat some_data | grep data
some data

If yes, then you probably call | a pipe. Where does this come from? Well, you actually pipe the output from one process as an input to another. You can do it with your own code as well – we are not limited to the system’s applications. And we can program this pipe communication in our own code, too. This is a fundamental instrument for the data transfer between processes. Do you remember reading earlier about FIFO files and named pipes? Yes, that’s right – they are the same thing, but is the |-symbolled pipe the same as them? No! That’s an anonymous pipe. System programmers differentiate between the so-called anonymous pipes and the named pipes. They have different purposes, so both of them are found on Linux systems nowadays. They are created and managed by pipefs...