AuthorMia Combeau

Student at 42Paris, digital world explorer. I code to the 42 school norm, which means for loops, switches, ternary operators and all kinds of other things are out of reach... for now!

IPv4 Addresses, Routing and Subnet Masks

I

IPv4 addresses are the most common on the Internet. How can they uniquely identify every connected object? How do they facilitate data routing from one side of this vast network to the other? And why are they progressively being replaced by IPv6 addresses? We will attempt to answer these questions in this article. But before that, it wouldn’t be a bad idea to remind ourselves of the...

Sending and Intercepting a Signal in C

S

Anyone who’s ever been confronted to segfaults and bus error will already be familiar with the idea of signals. We get a SIGSEGV or a SIGBUS which ends our program’s execution without notice, without explanation and without appeal. But what really is a signal? Is it more than just the operating system’s police baton? And how can we send, block and even intercept one within our...

Threads, Mutexes and Concurrent Programming in C

T

For efficiency or by necessity, a program can be concurrent rather than sequential. Thanks to its concurrent programming and with its child processes or threads and mutexes, it will be able to perform multiple tasks simultaneously. In a previous article, we came to understand how to create child processes, which are one way to implement concurrent programming. Here, we will concentrate on threads...

Errno and Error Management in C

E

Underlying any software development is program error detection and analysis. But then an external library function or system call fails, how can we understand what went wrong? These functions usually return -1 or NULL, but they also store the reason behind their failure in errno. Let’s see what errno actually is, and how to retrieve, interpret and print it out. What is Errno? Errno...

Pipe: an Inter-Process Communication Method

P

By default, it is difficult to get two processes to communicate with each other. As we’ve seen in a previous article, even parent and child processes don’t share the same memory space. So we need to find ways to establish inter-process communication. One of these communication mechanisms is the pipe. What is a Pipe? A pipe is a section of shared memory meant to facilitate the...

Handling a File by its Descriptor in C

H

The available system calls to create or open, read, write, and delete a file in C all make use of a file descriptor. So let’s discover how the operating system handles references to open files and how to manipulate files in our programs. What is a File Descriptor? In Unix type systems, a file descriptor (fd for short) is a small positive integer used as reference to an open file in a...

Creating and Killing Child Processes in C

C

In order to execute another program within ours or to execute part of our program simultaneously, it can often be very useful to create child processes. Then, all we need to do is patiently wait for them to finish their tasks, or, if we’re feeling particularly murderous, kill them prematurely! So what exactly is a process? How can we create child processes, and why wait for them or kill...

Why I No Longer Write Articles About 42 School Projects

W

Following a meeting with 42 school’s pedagogical team, I decided to remove all articles directly related to 42 projects. The most rewarding part of every project is the whole research, testing, failing and researching again process that finally leads to a viable solution. And I wouldn’t want to deprive anyone of this journey. By digging a little deeper into this site, you will find...

The Internet’s Layered Network Architecture

T

We all know the Internet. It’s the network that enables data transfer on a global scale. Its magnitude is staggering: there are about 5 billion users, 200 million active websites, 300 billion emails sent daily and 40 thousand Google searches every second. We access it by different means (WiFi, optical fiber, coaxial cable…), and with various devices (computers, smartphones...

Coloring Terminal Text: tput and ANSI Escape Sequences

C

A terminal with black-on-white text or vice versa is not very interesting or attractive or informative. Thankfully, modern terminal emulators offer a variety of text styling options as well as foreground and background colors. It’s just a matter of knowing how to apply them with ANSI escape sequences or the tput command. We will explore both methods in this article. How a Terminal Formats...