Book Image

Linux System Programming Techniques

By : Jack-Benny Persson
5 (1)
Book Image

Linux System Programming Techniques

5 (1)
By: Jack-Benny Persson

Overview of this book

Linux is the world's most popular open source operating system (OS). Linux System Programming Techniques will enable you to extend the Linux OS with your own system programs and communicate with other programs on the system. The book begins by exploring the Linux filesystem, its basic commands, built-in manual pages, the GNU compiler collection (GCC), and Linux system calls. You'll then discover how to handle errors in your programs and will learn to catch errors and print relevant information about them. The book takes you through multiple recipes on how to read and write files on the system, using both streams and file descriptors. As you advance, you'll delve into forking, creating zombie processes, and daemons, along with recipes on how to handle daemons using systemd. After this, you'll find out how to create shared libraries and start exploring different types of interprocess communication (IPC). In the later chapters, recipes on how to write programs using POSIX threads and how to debug your programs using the GNU debugger (GDB) and Valgrind will also be covered. By the end of this Linux book, you will be able to develop your own system programs for Linux, including daemons, tools, clients, and filters.
Table of Contents (14 chapters)

Preface

Linux system programming is all about developing system programs for the Linux operating system. Linux is the world's most popular open-source operating system and runs on everything from big servers to small Internet of Things (IoT) devices. Knowing how to write system programs for Linux will enable you to extend the operating system and connect it with other programs and systems.

We'll start by learning how to make our programs easy to script and easy to interact with other programs. When we write system programs for Linux, we should always strive to make them small and do one thing only—and do it well. This is one of the key concepts in Linux: to create small programs that can exchange data with each other in simple ways.

As we move ahead, we'll take a deep dive into C and look at how the compiler works, what the linker does, how to write Makefiles, and much more.

Then, we'll learn all about forking and daemons. We'll also create our own daemon. We will then put our daemon under systemd's control. This will enable us to start, stop, and restart the daemon using built-in Linux tools.

We will also learn how to make our processes exchange information using different kinds of Inter-Process Communication (IPC). We'll also take a look at how to write threaded programs.

At the end of this book, we'll cover how to debug our programs using the GNU Debugger (GDB) and Valgrind.

By the end of this book, you'll be able to write a wide variety of system programs for Linux—everything from filters to daemons.