| 261 | |
| 262 | #ifndef HAVE_MMAP |
| 263 | static int shm_exclusive( SLONG key, SLONG length) |
| 264 | { |
| 265 | /************************************** |
| 266 | * |
| 267 | * s h m _ e x c l u s i v e |
| 268 | * |
| 269 | ************************************** |
| 270 | * |
| 271 | * Functional description |
| 272 | * Check to see if we are the only ones accessing |
| 273 | * shared memory. Return a shared memory id |
| 274 | * if so, -1 otherwise. |
| 275 | * |
| 276 | **************************************/ |
| 277 | struct shmid_ds buf; |
| 278 | |
| 279 | const int id = shmget(key, (int) length, IPC_ALLOC); |
| 280 | if (id == -1 || shmctl(id, IPC_STAT, &buf) == -1 || buf.shm_nattch != 1) |
| 281 | { |
| 282 | return -1; |
| 283 | } |
| 284 | |
| 285 | return id; |
| 286 | } |
| 287 | #endif |