#include #include #include #include #include #include "nya/common.h" #define PATH "/tmp/tmp_191944_s9/a" static int shm_id = 0; int main( int argc, char* argv[] ) { struct inf_t *data; time_t start; key_t key; int shmflg; size_t size = sizeof(struct inf_t); start = time(NULL); massert((key = ftok( PATH, 'a' )) < 0, "ftok" ); shmflg = 0600 | IPC_CREAT; massert((shm_id = shmget(key, size, shmflg)) < 0, "shmget"); data = (struct inf_t*)shmat( shm_id, NULL, 0); if( data == (struct inf_t*)(-1)) { perror("shmat"); exit(-1); } print_inf( data ); massert(shmdt((void*)data) < 0, "shmdt"); return 0; }