[squid-users] SIGBUS attempting to use rock
Antonio SJ Musumeci
trapexit at spawn.link
Fri Oct 18 14:25:06 UTC 2019
On 10/18/2019 9:49 AM, Alex Rousskov wrote:
> Actually, the location of shared memory segments is chosen by the OS.
> Not all OSes do what Linux does. The code dealing with [naming] shared
> memory segments is more complicated than you probably imagine. However,
> let's not spend time arguing about these low-level specifics here: If
> you can contribute an improvement, please post a plan on squid-dev.
> Otherwise, let's leave these low-level details to those contributing
> improvements.
You don't need to know where the OS put the file (though /dev/shm is a
well known location and easily could be checked explicitly).
$ man fstatvfs
The attached example seems to work fine and could be incorporated into
ipc/mem/Segment.cc.
I'd be happy to post this on squid-dev / submit a pull request.
-------------- next part --------------
/*
$ gcc -o shm_statvfs shm_statvfs.c -lrt
*/
#include <fcntl.h>
#include <stdio.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/statvfs.h>
#include <unistd.h>
const char FILENAME[] = "statvfs.test.tmp";
int
main(int argc,
char *argv)
{
int rv;
int fd;
struct statvfs vfs;
fd = shm_open(FILENAME,O_CREAT|O_RDWR,S_IRUSR|S_IWUSR);
rv = fstatvfs(fd,&vfs);
printf("fstatvfs(%d,%p) = %d\n",fd,&vfs,rv);
if(rv == -1)
return 1;
printf("frsize: %ld\n"
"bavail: %ld\n"
"total avail: %ld\n",
vfs.f_frsize,
vfs.f_bavail,
vfs.f_frsize*vfs.f_bavail);
close(fd);
shm_unlink(FILENAME);
return 0;
}
More information about the squid-users
mailing list