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

Running services with init and systemd

Let’s use this opportunity to discuss the init and the systemd process daemons. There are others as well, but we’ve decided to retain our focus on these two. The first one is the initial process, executed on a Linux system by the kernel, and its pid is always 1:

$ ps -p 1
PID TTY          TIME CMD
1 ?        04:53:20 systemd

It is known as the parent of all processes on the system as it is used to initialize, manage, and track other services and daemons. The first init daemon for Linux is called Init and it defines six system states. All system services are mapped to those states, respectively. Its script is used to start processes in a pre-defined order, which is occasionally used by system programmers. One possible reason to use this is to reduce the startup duration of the system. To create a service or edit the script, you could modify...