Rainer Weikusat via Dng said on Sat, 04 Apr 2026 17:49:30 +0100
>Steve Litt <slitt@???> writes:
>> Kevin Chadwick via Dng said on Fri, 3 Apr 2026 10:23:31 +0100
>>
>>>-------- Original Message --------
>>>
>>>> which uses assert for invarant checks in the context of the init
>>>> process. Should these asserts ever trigger, they'll stop the
>>>> program via abort which will cause a kernel panic because init is
>>>> special can just exit in case of a runtime error. But why would
>>>> people programming in the context of init take that into account?
>>>>
>>>
>>>Ada SPARK would be a great choice of language for pid 1 actually. As
>>>you could I guess quite easily prove it to Silver level and be sure
>>>it could never crash (AORE; absence of runtime errors).
>>
>> OK, let's do it. Let's start with a PID1 that does nothing but run a
>> single shellscript and receive incoming signals. The 16 line C
>> program for a PID1 that runs a shellscript shellscript and nothing
>> else can be seen toward the bottom of http://ewontfix.com/14/ . The
>> Suckless Tools version, which is more like 83 lines plus some .h
>> code and responds to incoming signals, can be quickly and simply
>> downloaded with:
>>
>> git clone git://git.suckless.org/sinit
>>
>> Serious business, tell me how to write the 16 line
>> only-runs-shellscript version in Ada Spark.
>
>If you want a truly minimal init, this here should do:
>
>----
>int main(void)
>{
> extern int wait(int *);
> while (1) wait(0);
> return 0;
>}
>----
>
>that's the part which keeps running. It can be combined with a
>shell-script which could look like this:
>
>----
>#!/bin/sh
>launch /etc/startup
>exec reaper
>----
>
>to start the script /etc/startup as background process and then execute
>the waiting program (named reaper for the sake of this example).
>
>NB: I didn't test if running a shell script with a she-bang line as
>init actually works. In theory, it should, though.
You didn't know this, but both Kevin and I have a fondness for Ada. I
like Ada for the same reasons I like Rust. By building an init system
based on Ada Spark plus shellscripts, Kevin and I strike a blow for Ada.
Rainer, I like C. I've used it since 1985. It's a tiny, simple
language, the most DIY friendly compiled or interpreted language I've
ever used. C is the perfect language for construction by functional
decomposition. You can write a C program by linear thinking.
But I am what I am, I make mistakes, and with my personality it would
be easier for me to become an expert at Ada and Rust than to write
mistake-free C. I'll freely admit it: I need a language to protect me
from my own stupidity, and both Ada and Rust do that. My carelessness
is also why I won't use assembler or Perl, and I try to be very careful
when using Python.
SteveT
Steve Litt
http://444domains.com