1 year ago
#371175
tsp
check whether shared memory is attached or not
I am implementing with shared memory.
In order to access the same shared memory, whenever the shared memory address assigned pid
and the current pid
are different, the address is reassigned through system V's shmat
.
When the child process
terminates or the parent process
deletes the shared memory, it shmdt
the last shmat
address and shmctl
the shared memory id
.
I think this is correct behavior for spawn
, but is this also correct behavior for fork
?
If I use fork
, I expect the same memory access without shmat
even though the pid
is different.
If it was a process created with fork
, when it had the id and address of the shared memory, I thought that the child process
should either run shmdt
on the existing address or update the pid
.
- Is there a way to check if the id and address of the shared memory that the process has are valid?
- Does
shmdt
in a forked child process not affect the parent process? (Does the parent process still access to shared memory well?) - Is it necessary to
shmdt
all shared memory owned by theparent process
in thechild process
created byfork
in order for normalshmctl
to proceed?
c
multiprocessing
fork
shared-memory
spawn
0 Answers
Your Answer