Passing a pointer to process spawned with exec()

后端 未结 6 1288
花落未央
花落未央 2021-01-23 14:44

I would like to pass a pointer (I am putting a file with data in memory with mmap) to processes spawned using fork + exec, but I am stuck on how to pass a pointer to the exec()

6条回答
  •  盖世英雄少女心
    2021-01-23 14:59

    The spawned process should probably open a pipe back to the parent process and ask for the data it needs to map the shared memory segment.

    Alternatively you can use boost::interprocess to create a shared memory segment for you and actually pass around the address (it can do the mapping). You're on your own reading that documentation though: http://www.boost.org/doc/libs/1_38_0/doc/html/interprocess.html

提交回复
热议问题