This commit is contained in:
Lorenzo Bianchi 2023-05-14 21:44:03 +02:00
parent 0f2fac98cf
commit 857c119213
3 changed files with 9 additions and 4 deletions

View File

@ -1,5 +1,6 @@
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <server.h>
#include <structures.h>
@ -8,7 +9,10 @@
int main(int argc, char *argv[]){
input_server_t input = check_input(argc, argv);
int shmid = getShmid();
int shmBoardid = getShmid(sizeof(int) * input.collums * input.rows);
shm_t *shm = shmat(shmBoardid, NULL, 0);
return 0;
}

View File

@ -4,12 +4,12 @@
#include <structures.h>
#include <errExit.h>
int getShmid() {
int result = shmget(ftok(KEYFILE, 'a'), SHM_SIZE, IPC_CREAT | S_IRUSR | S_IWUSR);
int getShmid(size_t size) {
int shmid = shmget(ftok(KEYFILE, 'a'), size, IPC_CREAT | S_IRUSR | S_IWUSR);
if (result == -1) {
errExit("shmget", "getShmid");
}
return result;
return shmid;
}

View File

@ -2,6 +2,7 @@
#include <stdlib.h>
#include <ctype.h>
#include <server.h>
#include <errExit.h>
input_server_t check_input(int argc, char *argv[]){