ukrbublik / shm-typed-array

IPC shared memory for NodeJs. Use as Buffer or TypedArray.
MIT License
71 stars 9 forks source link

Attach'ing problem relevant with flags IPC_CREAT | IPC_EXCL #9

Open enseitankado opened 4 years ago

enseitankado commented 4 years ago

There is no attach method for outside of node.js environments. I created a SHM in C++ but the node cant attach with it. To have access to shm, it must have created it own.

Another problem is: I'm creating a shm with a key and can reading in same execution session but I start a new execution with same key to read previous data then create method returns null and failing. Because of theresi is no attach method and create method already has IPC_EXCL flag.

Please your attention:

res = shm.get(key, count, shm.IPC_CREAT|shm.IPC_EXCL|perm, 0, type);

I think that if second flag (IPC_EXCL) will be ommitted from create method then the problem above solved and the create method can create a new and can attach already one.

Also, if we consider the server environment safe, the permissions must be set to 666 for another program to read and write.

Ref: https://man7.org/linux/man-pages/man2/shmget.2.html