2008-06-13から1日間の記事一覧

とりあえず共有メモリを使ってみる

開いて閉じるだけ。munmapは必要なのかな? #include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <unistd.h> #include <sys/types.h> #include <sys/mman.h> #include <errno.h> #define SHM_NAME "foo" #define SHM_SIZE 256 int main() { int fd; char *p; if ((fd = shm_open(SHM_NAME, O_CREAT | O_RDWR, 0666)) </errno.h></sys/mman.h></sys/types.h></unistd.h></fcntl.h></stdlib.h></stdio.h>…