website

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

20201002-reimplementing-sysmgr-in-c.html (3254B)


      1 <!DOCTYPE HTML>
      2 <html lan=en>
      3   <head>
      4     <title>Reimplementing `sysmgr` in C | Cem's Website</title>
      5     <meta charset="utf-8">
      6     <meta name="Description" content="Cem Keylan's Website">
      7     <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
      8     <style>
      9       html {font-family:monospace;font-size:16px;color:#282a36;}
     10       body {
     11 	  width: 90%;
     12 	  max-width: 1050px;
     13 	  margin-left: auto;
     14 	  margin-right: auto;
     15 	  margin-top: 20px;
     16 	  overflow: none;
     17           overflow-y: scroll;
     18 	  padding-right: 10px;
     19 	  padding-left: 10px;
     20       }
     21       a{text-decoration:none;font-weight:bold;color:#282a36;}
     22       a:hover{text-decoration:underline;}
     23       @media (prefers-color-scheme: dark) {
     24           html {color: white;background:#282a36;}
     25           a{color:white;}
     26       }
     27     </style>
     28     <link rel="stylesheet" href="/static/syntax.css">
     29     <script src="/static/highlight.pack.js"></script>
     30     <script>hljs.initHighlightingOnLoad();</script>
     31   </head>
     32   <body>
     33     <div class="header">
     34       <nav>
     35         <a href='/'>index</a> |
     36         <a href="/software.html">software</a> |
     37         <a href="/blog.html">blog</a> |
     38         <a href="/contact.html">contact</a> |
     39         <a href="/sysmgr">sysmgr</a> |
     40       </nav>
     41     </div>
     42     <hr>
     43     <p>
     44 <h1>Reimplementing <code>sysmgr</code> in C</h1>
     45 
     46 <p>For a while, I have been thinking about implementing <a href="https://git.ckyln.com/sysmgr">sysmgr</a> in C. I started
     47 thinking about the inefficiencies of sysmgr. POSIX sh isn&rsquo;t particularly
     48 designed to have ultimate control over child processes. There are basic job
     49 management features that are <em>just enough</em> for sysmgr to do its job. The
     50 biggest pain is having to use tools like <code>sleep(1)</code> and <code>kill(1)</code>. Calling
     51 sleep every second, and using the kill command to check whether a process is
     52 alive or not is extremely inefficient. Some shells <em>do</em> include these commands
     53 built-in, but it isn&rsquo;t specified by POSIX, but one should never take this as
     54 granted.</p>
     55 
     56 <p>Lately, I have been adding C utilities to sysmgr to make it more efficient. This
     57 defeats the initial purpose of sysmgr, being a service manager in pure POSIX
     58 shell. My main purpose, however, is making sysmgr efficient and simplistic. It
     59 mostly imitates <code>runit</code> without dealing with all the complexity of the
     60 over-thinked <code>supervise</code> directory, nor the logging stuff. Most of these can be
     61 handled by the service script itself anyway. That&rsquo;s why instead of this ugly
     62 C/POSIX sh hybrid, I decided to implement it all in C.</p>
     63 
     64 <p>I am not a C expert or anything, I am learning a lot as I am writing the
     65 program. I want it to be C99 and portable (for BSD). It&rsquo;s currently not
     66 functional at all, but, you can see its current state <a href="https://git.ckyln.com/sm">here</a>.</p>
     67 
     68 <p>EDIT Oct 10 2020:</p>
     69 
     70 <p>I did the initial release of this C version of sysmgr, which is more stable,
     71 and performant than the POSIX sh version. It still has rough edges, but is
     72 completely usable.</p>
     73     </p>
     74     <a href="/blog/20201002-reimplementing-sysmgr-in-c.txt">This page in plain-text</a>
     75     <hr>
     76     <p class=footer>Copyright &copy; 2019-2021 Cem Keylan</p>
     77   </body>
     78 </html>