Reimplementing sysmgr in C

For a while, I have been thinking about implementing sysmgr in C. I started thinking about the inefficiencies of sysmgr. POSIX sh isn’t particularly designed to have ultimate control over child processes. There are basic job management features that are just enough for sysmgr to do its job. The biggest pain is having to use tools like sleep(1) and kill(1). Calling sleep every second, and using the kill command to check whether a process is alive or not is extremely inefficient. Some shells do include these commands built-in, but it isn’t specified by POSIX, but one should never take this as granted.

Lately, I have been adding C utilities to sysmgr to make it more efficient. This defeats the initial purpose of sysmgr, being a service manager in pure POSIX shell. My main purpose, however, is making sysmgr efficient and simplistic. It mostly imitates runit without dealing with all the complexity of the over-thinked supervise directory, nor the logging stuff. Most of these can be handled by the service script itself anyway. That’s why instead of this ugly C/POSIX sh hybrid, I decided to implement it all in C.

I am not a C expert or anything, I am learning a lot as I am writing the program. I want it to be C99 and portable (for BSD). It’s currently not functional at all, but, you can see its current state here.

EDIT Oct 10 2020:

I did the initial release of this C version of sysmgr, which is more stable, and performant than the POSIX sh version. It still has rough edges, but is completely usable.

This page in plain-text