How to execute process with mmap-ed memory as stdin and another mmap-ed memory as stdout?

59 Views Asked by At

It is possible in Linux execute process with mmap-ed memory as stdin and another mmap-ed memory as stdout, so parent program can preallocate memory for stdin, write necessary data, execute program and read their output from memory not using temporary files or pipes?

I can create shared memory object, set it size with 'ftruncate' and map it. Thus i have file descriptor, but what next? How can i pass it to child process invoked by std::system or exec.

int fd = shm_open( "/my_stdin", O_CREAT | O_RDWR, 0 );

size_t size = 100;
ftruncate( fd, size )

char * p_shm = (char *)mmap( 0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0 );

...?
0

There are 0 best solutions below