1
votes

I have some legacy code that uses shmget/shmat/shmdt to create, attach and manage shared memory segments.

The app with the code sometimes crashes, leaving the segments in memory. The code re-uses same segment key to reconnect to them, but the problem it uses different shared memory sizes every time, and unable to connect because of this.

My question is:

1) Is it possible to change the shared memory size on connection?

2) If not, how I can connect to the shared memory segment (even if I might not know the size), in order to erase it (for later re-creation of a newer one)?

Thanks!

1

1 Answers

1
votes

You can use shmctl to delete and create one of your own size. I presume the legacy code will try to use the existing shared memory if it is not able to shmget?