Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Linux System Programming Techniques
Linux System Programming Techniques

Linux System Programming Techniques: Become a proficient Linux system programmer using expert recipes and techniques

Arrow left icon
Profile Icon Jack-Benny Persson
Arrow right icon
S$42.99 S$47.99
Full star icon Full star icon Full star icon Full star icon Half star icon 4.8 (8 Ratings)
eBook May 2021 432 pages 1st Edition
eBook
S$42.99 S$47.99
Paperback
S$59.99
Subscription
Free Trial
Arrow left icon
Profile Icon Jack-Benny Persson
Arrow right icon
S$42.99 S$47.99
Full star icon Full star icon Full star icon Full star icon Half star icon 4.8 (8 Ratings)
eBook May 2021 432 pages 1st Edition
eBook
S$42.99 S$47.99
Paperback
S$59.99
Subscription
Free Trial
eBook
S$42.99 S$47.99
Paperback
S$59.99
Subscription
Free Trial

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Linux System Programming Techniques

Chapter 2: Making Your Programs Easy to Script

Linux and other Unix systems have strong scripting support. The whole idea of Unix, from the very beginning, was to make a system easy to develop on. One of these features is to take the output of one program and make it the input of another program—hence building new tools with existing programs. We should always keep this in mind when creating programs for Linux. The Unix philosophy is to make small programs that do one thing only—and do it well. By having many small programs that do only one thing, we can freely choose how to combine them. And by combining small programs, we can write shell scripts—a common task in Unix and Linux.

This chapter will teach us how to make programs that are easy to script and easy to interact with other programs. That way, other people will find them much more useful. It's even likely they will find new ways of using our programs that we haven't even thought of, making the programs more popular and easier to use.

In this chapter, we will cover the following recipes:

  • Return values and how to read them
  • Exiting a program with a relevant return value
  • Redirecting stdin, stdout, and stderr
  • Connecting programs using pipes
  • Writing to stdout and stderr
  • Reading from stdin
  • Writing a pipe-friendly program
  • Redirecting the result to file
  • Reading environment variables

Let's get started!

Technical requirements

All you need for this chapter is a Linux computer with GCC and Make installed, preferably via one of the meta-packages or group installs mentioned in Chapter 1, Getting the Necessary Tools and Writing Our First Linux Programs. It's also preferable if you use the Bash shell for optimal compatibility. Most of the examples will work with other shells as well, but there's no guarantee that everything will work the same way on every possible shell out there. You can check which shell you are using by running echo $SHELL in your terminal. If you are using Bash, it will say /bin/bash.

You can download all the code for this chapter from https://github.com/PacktPublishing/Linux-System-Programming-Techniques/tree/master/ch2.

Check out the following link to see the Code in Action video: https://bit.ly/3u5VItw

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Develop a deeper understanding of how Linux system programming works
  • Gain hands-on experience of working with different Linux projects with the help of practical examples
  • Learn how to develop your own programs for Linux

Description

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.

Who is this book for?

This book is for anyone who wants to develop system programs for Linux and gain a deeper understanding of the Linux system. The book is beneficial for anyone who is facing issues related to a particular part of Linux system programming and is looking for specific recipes or solutions.

What you will learn

  • Discover how to write programs for the Linux system using a wide variety of system calls
  • Delve into the working of POSIX functions
  • Understand and use key concepts such as signals, pipes, IPC, and process management
  • Find out how to integrate programs with a Linux system
  • Explore advanced topics such as filesystem operations, creating shared libraries, and debugging your programs
  • Gain an overall understanding of how to debug your programs using Valgrind

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : May 07, 2021
Length: 432 pages
Edition : 1st
Language : English
ISBN-13 : 9781789959789
Category :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : May 07, 2021
Length: 432 pages
Edition : 1st
Language : English
ISBN-13 : 9781789959789
Category :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just S$6 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just S$6 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total S$ 209.97
Linux Kernel Programming
S$74.99
Linux System Programming Techniques
S$59.99
Mastering Embedded Linux Programming
S$74.99
Total S$ 209.97 Stars icon

Table of Contents

13 Chapters
Chapter 1: Getting the Necessary Tools and Writing Our First Linux Programs Chevron down icon Chevron up icon
Chapter 2: Making Your Programs Easy to Script Chevron down icon Chevron up icon
Chapter 3: Diving Deep into C in Linux Chevron down icon Chevron up icon
Chapter 4: Handling Errors in Your Programs Chevron down icon Chevron up icon
Chapter 5: Working with File I/O and Filesystem Operations Chevron down icon Chevron up icon
Chapter 6: Spawning Processes and Using Job Control Chevron down icon Chevron up icon
Chapter 7: Using systemd to Handle Your Daemons Chevron down icon Chevron up icon
Chapter 8: Creating Shared Libraries Chevron down icon Chevron up icon
Chapter 9: Terminal I/O and Changing Terminal Behavior Chevron down icon Chevron up icon
Chapter 10: Using Different Kinds of IPC Chevron down icon Chevron up icon
Chapter 11: Using Threads in Your Programs Chevron down icon Chevron up icon
Chapter 12: Debugging Your Programs Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.8
(8 Ratings)
5 star 87.5%
4 star 0%
3 star 12.5%
2 star 0%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Mouad Mar 25, 2024
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Thank you so much artistic style to learn seamlessly
Subscriber review Packt
April Jun 02, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This is a well written book that gives you everything you need to know about Linux Programming. It provides practical examples and lays things out in a easy to learn manner. Highly Reccomended
Amazon Verified review Amazon
Ramon Fried Jun 13, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Full disclosure: I was the technical reviewer for the book.This is an excellent book for beginners and intermediate developers who would like to extend their knowledge in system programming.It gives practical examples and recipes around the most important concepts of system development: Working with files, manipulating streams, dealing with errors, etc.
Amazon Verified review Amazon
Amazon Customer May 25, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I was always very fond of Linux and Jack-Benny has done an excellent job in writing this book. It is a very in-depth resource for anyone who is interested in Linux system programming techniques.
Amazon Verified review Amazon
Donald A. Tevault May 24, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This is a nicely written book that can be enjoyed by both beginner and advanced C programmers. It starts out by explaining the basics of installing and using C programming tools on a Linux system, and goes all the way through to more advanced topics like creating your own system daemons. Instead of bogging you down with long treatises about programming theory, the author demonstrates everything with working program code, and then explains what's going on with it. The explanations are clear, concise, and easy-to-read. If you want to get into C programming for Linux systems, you won't go wrong by picking up a copy of this book.Full disclosure: I'm a fellow author for Packt Publishing.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.