This commit is contained in:
Lorenzo Bianchi 2023-05-14 21:51:56 +02:00
commit aae21bf724
6 changed files with 11 additions and 6 deletions

View File

@ -1,3 +1,3 @@
# Elaborato_SO
Edi iper ghei
Lore iper ghei

View File

@ -1,9 +1,6 @@
#ifndef SIGNAL_H
#define SIGNAL_H
#define DEFAULT_SIGINT 2
#define TIME_TO_RESET 10
#include <signal.h>
void serverSigHandler(int sig);

View File

@ -1,6 +1,8 @@
#ifndef STRUCTURES_H
#define STRUCTURES_H
#define KEYFILE "../LICENSE"
// semaphore
@ -31,5 +33,8 @@ typedef struct {
static const size_t SHM_SIZE = sizeof(shm_t);
// signal
#define DEFAULT_SIGINT 2
#define TIME_TO_RESET 10
#endif

View File

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

View File

@ -3,6 +3,7 @@
#include <unistd.h>
#include <custom_signal.h>
#include <structures.h>
void serverSigHandler(int sig) {
static int sigint_count = DEFAULT_SIGINT;