/images/p1.jpg

Hi, I'm Tomasz

I'm a professional C++ software engineer with over a decade of hands on development experience with variety of technologies (mostly Linux & embedded systems). This is my blog.

Find me on social media

Handling signals in Linux with C++

Why signals are important Signals are the simplest form of IPC in Unix-like systems. They are notifiers to the process that an external event has happened. As this is a system specific mechanism, there’s no portable C++ STL library providing support for signal handling. But it’s fairly easy to write one. First though a short introduction is required. Signal disposition Each thread in a process has a signal mask which can be modified either via setprocmask (for single threaded processes) or pthread_sigmask (for multithreaded processes).

Callbacks in C++ API design

Callbacks are a perfect way for clients to interface with an API abstracting an events source. How to design an API for such abstraction to make it unambiguous and easy to use? The simplest choice is functor injection, similarly as it is done in many places in STL (or even C stdlib by means of function pointers). Can we do better though? What are the alternatives available? In this post, I’ll try to provide a step by step overview of a design process for an imaginary HttpServer class.