blog.8-p.info

SIGRTMIN is tricky

Aug 2, 2021

I was working on a pull request to support real-time signals in containerd. While the merged change is using github.com/moby/sys, I went the DIY way first and learned a bit about real-time signals, or more specifically saying SIGRTMIN.

According to signal(7);

The range of supported real-time signals is defined by the macros SIGRTMIN and SIGRTMAX.

However, containerd is avoiding cgo unless it is absolutely necessary. So I wanted to define SIGRTMIN by myself, which is tricky.

Again from the same manpage;

The Linux kernel supports a range of 33 different real-time signals, numbered 32 to 64. However, the glibc POSIX threads implementation internally uses two (for NPTL) or three (for LinuxThreads) real-time signals (see pthreads(7)), and adjusts the value of SIGRTMIN suitably (to 34 or 35).

This man page is flatly comparing NPTL and LinuxThreads, but LinuxThreads is an ancient threads implementation in Linux. You really don’t have to worry about. That being said, the man page only talks about glibc, GNU’s libc implementation. There is musl libc, which defines SIGRTMIN as 35.

Back to the containerd story. We decided that it would be better to be compatible with Docker, Sebastiaan extracted the part as moby/sys/signal and we simply took it.