Passing a pointer to process spawned with exec()

后端 未结 6 1289
花落未央
花落未央 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 15:19

    If you use shared memory, you can't pass the pointer. The pointer will contain the virtual address, which is different from one process to another. You have to exchange offset values, based on the start of the shared memory area.

    If you don't use shared memory, you can't exchange pointers of any kind: The other process won't be able to access the memory of your process.

提交回复
热议问题