fx.io: import system-level streams and uni-directional pipes
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
#include <fx/io/pipe.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
fx_iostream *read = NULL, *write = NULL;
|
||||
fx_status status = fx_pipe_create(&read, &write);
|
||||
|
||||
if (!FX_OK(status)) {
|
||||
fprintf(stderr,
|
||||
"failed to create pipe: %s\n",
|
||||
fx_status_description(status));
|
||||
return -1;
|
||||
}
|
||||
|
||||
fx_stream_write_cstr(write, "Hello, world!\n", NULL);
|
||||
|
||||
char buf[128];
|
||||
fx_stream_read_line(read, buf, sizeof buf);
|
||||
|
||||
printf("read from pipe: %s\n", buf);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user