Init for Linux in crystal: pthread_getattr_np no such file or directory

Hi guys, I would like actually to write my own init system in crystal, but when I did a first test in a virtual machine, when the linux kernel give the control to my init program, I got this error (during booting process):

pthread_getattr_np no such file or directory

The error strangely is not always exactly the same. I took a screenshot:


Any idea ?

Another error I can get:

Do you think maybe I should build the init system statically ? (probably it will make sens)

Sounds likely, yes.

Statically it work :grimacing:

But now I am facing an issue.

I made a function to print a text char by char but with delay. But when the program is run just after the kernel, it’s like the function is ignored.

I guess the functionnality is not available at the init boot time. How can I proceed ?

I used sleep function

This is the code I tried with the sleep function (it work if run from a terminal in graphical environment):

def progressivePrint(text : String, speed = 20_000_000)
            text.each_char do |character|
                sleep(Time::Span.new(nanoseconds: speed))
                print character
            end
        end

And another try with Time.monotic:

def progressivePrint(text : String, speed = 20)
            text.each_char do |character|
                startingTime = Time.monotonic

                loop do
                    if (Time.monotonic - startingTime).milliseconds > speed
                        break
                    end
                end

                print character
            end

        end

I suspect these functionalities are not availables at boot time. There is a way maybe when I compile statically to link these function too ?

And another question: is it possible to silent the GC warnings ?

So I suspect something. I think because the wiki recommend to build statically with alpine linux with musl (Static Linking - Crystal), I think sometime the binary is not read properly.

Because if I try multiple time to boot, sometime the binary don’t work.

Is there any other way to build statically, but with glibc for example ?

So I find why. I don’t need to make the init static, it’s just I need to mount proc before I start the init and remount root with read and write access.

So I have only one problem now. Why when I call the command sleep, it don’t work ? How is working this crystal call ? What is normally need as minimum ?