On 23.11.2012, at 18:12, Igor Stasenko <[email protected]> wrote: > On 23 November 2012 18:00, Max Leske <[email protected]> wrote: >> Ok, thanks Igor. >> >> So it seems the only remaining option (apart from providing a C library) it >> to use Assembly. Assembly is not my territory at all but here's how I think >> it could work: >> >> … >> emitCall: [:gen | | fork dup2 execv | >> fork := NativeBoost forCurrentPlatform >> getGlobalSymbolPointer: 'fork'. >> dup2 := NativeBoost forCurrentPlatform >> getGlobalSymbolPointer: 'dup2'. >> execv := NativeBoost forCurrentPlatform getGlobalSymbolPointer >> gen asm mov: fork asUImm32 to: gen asm EAX. >> gen asm call: gen asm EAX. >> "somehow get the fork return value and test for 0. >> only execute the following lines if pid = 0" >> gen asm mov: dup2 asUImm32 to: gen asm EAX. >> gen asm call: gen asm EAX. >> gen asm mov: execv asUImm32 to: gen asm EAX. >> gen call: gen asm EAX. >> ] >> >> As you can see, I have absolutely no clue what I'm doing :) (just a good >> copycat). I figure that everything from fork() to exec() needs to be in the >> same Assembly sequence to ensure that the child process doesn't try to >> execute VM code (multiple #emitCall:'s probably wouldn't work). >> >> I think that if you could help me fill in the code for where I simply used a >> comment, I could come up with the rest (writing function specs etc.). I'l >> try at least. >> > > yes i can help. where i can get the code? > btw, your code is actually very close to how it should be done.
Awesome! The Smalltalk code is here: http://ss3.gemstone.com/ss/Limbo.html. The C code is on Github: https://github.com/theseion/liblimbo. Functions: fork() -> LimboFork dup2() -> LimboDup2 close() -> LimboPipe execv() -> LimboFork Please ignore the hideousness of the code, I'm just trying to get it to work before doing it nice and clean. > >> Cheers, >> Max >> > > > > -- > Best regards, > Igor Stasenko. >
