#include #include #include #include #include #include "common.h" 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); key = getuid() + 6661; 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; }