ferus-web / ferus

A toy web engine written in Nim
106 stars 4 forks source link

libferuscli changes #1

Closed xTrayambak closed 1 year ago

xTrayambak commented 1 year ago

It should now use fork(1) instead of what it does right now, as forking is less error prone, and it spawns the process as a child. Only a few changes are to be made: [ ] libferuscli should call os.fork() at initialization, and should kill itself if the fork syscall fails. [ ] The broker now just needs to import libferuscli and execute a function in it. [ ] To be less misleading, libferuscli should be renamed to ferus-child and no longer needs a separate binary.

xTrayambak commented 1 year ago

It seems fully eliminating libferuscli is a bad idea, instead, the child init process should go like this: broker.createProcess() -> execCmd("./libferuscli ") -> [inside libferuscli] feruschild.summon() -> libferuscli process dies, it's child lives on however.

xTrayambak commented 1 year ago

fork() is a bad idea, I tested it and seems to not work as everything starts running in a different process, as expected. For now, osproc.execCmd() is run in a different thread. Everything now works and this is no longer an issue.

xTrayambak commented 1 year ago

Also, the fork() idea isn't fully discarded in the first comment, it is still available via a compiler flag but it won't work as it is my least priority.