X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=ipc.c;h=d7f515dfec8788f267a41f8c33264d25b15abf8a;hp=9488224a1d4a622860adc957b27977e2bcbfc7e2;hb=5afe721aeb241bd21b832994ec2f2b7d8ff84766;hpb=e0f54e42887a8beef092755f5ed9cdf6d499bef2 diff --git a/ipc.c b/ipc.c index 9488224a..d7f515df 100644 --- a/ipc.c +++ b/ipc.c @@ -161,6 +161,27 @@ int shm_attach(int id, enum shm_attach_mode mode, void **result) return *result == (void *) -1? -ERRNO_TO_PARA_ERROR(errno) : 1; } +/** + * Get the size of a shared memory segment. + * + * \param id The shared memory segment identifier. + * \param result Size in bytes is returned here, zero on errors. + * + * \return Standard. + * + * \sa shmctl(2). + */ +int shm_size(int id, size_t *result) +{ + struct shmid_ds ds; /* data structure */ + + *result = 0; + if (shmctl(id, IPC_STAT, &ds) < 0) + return -ERRNO_TO_PARA_ERROR(errno); + *result = ds.shm_segsz; + return 1; +} + /** * Detach a shared memory segment. *