michaeljklein / CPlug

Hot plug C into Haskell, with automatic binding generation and recompilable instances (eventually)
http://michaeljklein.github.io/CPlug/
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Decide on pipe protocol #5

Closed michaeljklein closed 8 years ago

michaeljklein commented 8 years ago

So we've decided to use posix pipes to call/return from the recompiled C code. Great, as they're often very fast and should port to Linux without too much difficulty. Now we need to figure out what kind of protocol to use to pass back and forth.

Notes:

michaeljklein commented 8 years ago

1) I've decided to use a C import for the readers/writers 2) I'm using named pipes so mkfifo() 3) Reading/writing fixed-width "units" is being acheived by splitting into chars and then using putc/getc

michaeljklein commented 8 years ago

[15:30] MichaelK: why not just fork+exec? [15:31] o11c: that's brilliant. [15:35] o11c: just to check, the flow would be something like: local variable defined in main, path of newly compiled file new.c passed to main, main forks, main calls exec() to overwrite process with new.c, new process calls function on local variable defined in main, main can access results? [15:36] ah hm, if you want to get anything beyond a single byte that wouldn't work too well [15:36] MichaelK: actually, have you considered dlopen() if you trust the fresh code? [15:37] o11c: no, unfortunately I haven't googles [15:37] o11c: I do trust the code, as the program is generating it [15:41] o11c: I'm just floored that it's that easy (and unsafe, of course). [15:41] for more fun, there is a new interface, dlmopen, that lets you maintain entirely separate and incompatible sets of lbiraries [15:44] o11c: that also amazes me, but it doesn't look like I'd need it. (unless you think it'd be better practice to have the extra info or it'd help significantly with testing) [15:51] MichaelK: nah, you don't need it, it's just cool to keep these things in mind

So yeah, this is completely blown out of the water with how much it's solved.