Shared Memory With Two Processes In C?

后端 未结 4 1483
鱼传尺愫
鱼传尺愫 2021-01-03 07:42

I want to do the following:

Parent process creates a child process. Then the child process reads n int\'s from the user and store them in a shared memory. The parent

4条回答
  •  北海茫月
    2021-01-03 08:36

    My problem was so stupid. I need to provide the Child process with the ability to write into the SHM. This line in the if-block :

    shmid = shmget(2009, SHMSIZE, 0);
    

    Will become like this:

    shmid = shmget(2009, SHMSIZE, 0666 | IPC_CREAT);
    

    Thanks to you all and especially to @JoachimPileborg :)

提交回复
热议问题