in modules/fcgid/fcgid_proctbl_unix.c [64:120]
static apr_status_t apr_shm_remove(const char *filename, apr_pool_t * pool)
{
#if APR_USE_SHMEM_SHMGET
apr_status_t status;
apr_file_t *file;
key_t shmkey;
int shmid;
#endif
#if APR_USE_SHMEM_MMAP_TMP
return apr_file_remove(filename, pool);
#endif
#if APR_USE_SHMEM_MMAP_SHM
if (shm_unlink(filename) == -1) {
return errno;
}
return APR_SUCCESS;
#endif
#if APR_USE_SHMEM_SHMGET
/* Presume that the file already exists; just open for writing */
status = apr_file_open(&file, filename, APR_WRITE,
APR_OS_DEFAULT, pool);
if (status) {
return status;
}
/* ftok() (on solaris at least) requires that the file actually
* exist before calling ftok(). */
shmkey = ftok(filename, 1);
if (shmkey == (key_t) - 1) {
goto shm_remove_failed;
}
apr_file_close(file);
if ((shmid = shmget(shmkey, 0, SHM_R | SHM_W)) < 0) {
goto shm_remove_failed;
}
/* Indicate that the segment is to be destroyed as soon
* as all processes have detached. This also disallows any
* new attachments to the segment. */
if (shmctl(shmid, IPC_RMID, NULL) == -1) {
goto shm_remove_failed;
}
return apr_file_remove(filename, pool);
shm_remove_failed:
status = errno;
/* ensure the file has been removed anyway. */
apr_file_remove(filename, pool);
return status;
#endif
/* No support for anonymous shm */
return APR_ENOTIMPL;
}