website

My personal website
git clone git://git.ckyln.com/website
Log | Files | Refs

20201002-reimplementing-sysmgr-in-c.md (1723B)


      1 Reimplementing `sysmgr` in C
      2 ================================================================================
      3 
      4 For a while, I have been thinking about implementing [sysmgr] in C. I started
      5 thinking about the inefficiencies of sysmgr. POSIX sh isn't particularly
      6 designed to have ultimate control over child processes. There are basic job
      7 management features that are _just enough_ for sysmgr to do its job. The
      8 biggest pain is having to use tools like `sleep(1)` and `kill(1)`. Calling
      9 sleep every second, and using the kill command to check whether a process is
     10 alive or not is extremely inefficient. Some shells _do_ include these commands
     11 built-in, but it isn't specified by POSIX, but one should never take this as
     12 granted.
     13 
     14 Lately, I have been adding C utilities to sysmgr to make it more efficient. This
     15 defeats the initial purpose of sysmgr, being a service manager in pure POSIX
     16 shell. My main purpose, however, is making sysmgr efficient and simplistic. It
     17 mostly imitates `runit` without dealing with all the complexity of the
     18 over-thinked `supervise` directory, nor the logging stuff. Most of these can be
     19 handled by the service script itself anyway. That's why instead of this ugly
     20 C/POSIX sh hybrid, I decided to implement it all in C.
     21 
     22 I am not a C expert or anything, I am learning a lot as I am writing the
     23 program. I want it to be C99 and portable (for BSD). It's currently not
     24 functional at all, but, you can see its current state [here].
     25 
     26 [sysmgr]: https://git.ckyln.com/sysmgr
     27 [here]:   https://git.ckyln.com/sm
     28 
     29 EDIT Oct 10 2020:
     30 
     31 I did the initial release of this C version of sysmgr, which is more stable,
     32 and performant than the POSIX sh version. It still has rough edges, but is
     33 completely usable.