I have two programs in Linux (one in C++, one in python) which are communicating via interprocess-communications, using shared memory.
What I would need now is a shell-script I can invoke after both have finished, which deletes ALL shared memory segments for my linux user which are not used anymore (so have status 'dest' in the list I get from command 'ipcs -m').
So I do not want to keep of course shared memory segments which are in use by another user, and I want to keep shared memory segments which are currently used (e.g. by a Pytorch training running in parallel).
How can I achieve that on the command-line ? There are a lot of answers at Delete all SYSTEM V shared memory and semaphores on UNIX-like systems, but I think the do not check the status of the shared memory segment, and possibly also not to which user it belongs.