boh
This commit is contained in:
parent
12910fd7b6
commit
cdab1ff2cb
|
@ -52,3 +52,5 @@ Module.symvers
|
||||||
Mkfile.old
|
Mkfile.old
|
||||||
dkms.conf
|
dkms.conf
|
||||||
|
|
||||||
|
# Object directory
|
||||||
|
obj/
|
52
Makefile
52
Makefile
|
@ -0,0 +1,52 @@
|
||||||
|
# [--------------------DIRECTORIES--------------------]
|
||||||
|
# SRC_DIR is the source directory
|
||||||
|
# OBJ_DIR is the object directory
|
||||||
|
# INC_DIR is the header directory
|
||||||
|
SRC_DIR := src
|
||||||
|
OBJ_DIR := obj
|
||||||
|
INC_DIR := inc
|
||||||
|
|
||||||
|
# [--------------------COMPILE & RUN--------------------]
|
||||||
|
# CXX is the keyword to compile .c src files
|
||||||
|
# WFLAG is a flag to detect all the warnings
|
||||||
|
# OFLAG is the flag to rename the output of the compiler
|
||||||
|
# TARGET is the name of the output
|
||||||
|
# INCLUDE add to g++ path the custom include path
|
||||||
|
CXX := gcc
|
||||||
|
WFLAGS := -Wall
|
||||||
|
OFLAG := -o
|
||||||
|
TARGET := main
|
||||||
|
INCLUDE := -I $(INC_DIR)
|
||||||
|
|
||||||
|
|
||||||
|
# [--------------------FUNCTION--------------------]
|
||||||
|
# SRCS extract all file in src/
|
||||||
|
# FILES extract the name of the file
|
||||||
|
# OBJS concat obj/ + FILES + .o
|
||||||
|
SRCS := $(shell find $(SRC_DIR) -name "*.c")
|
||||||
|
FILES := $(notdir $(basename $(SRCS)))
|
||||||
|
OBJS := $(addprefix $(OBJ_DIR)/,$(addsuffix .o,$(FILES)))
|
||||||
|
|
||||||
|
|
||||||
|
#---------------------------------------------------
|
||||||
|
all: execute
|
||||||
|
#---------------------------------------------------
|
||||||
|
execute: linking
|
||||||
|
@ echo execute...
|
||||||
|
@ ./$(TARGET)
|
||||||
|
@ echo ...terminate
|
||||||
|
#---------------------------------------------------
|
||||||
|
linking: $(OBJS)
|
||||||
|
@ echo linking
|
||||||
|
@ $(CXX) $(WFLAGS) $(OFLAG) $(TARGET) $(OBJS)
|
||||||
|
#---------------------------------------------------
|
||||||
|
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c $(OBJ_DIR)
|
||||||
|
@ echo compile $<
|
||||||
|
@ $(CXX) $(WFLAGS) -c $< $(OFLAG) $@ $(INCLUDE)
|
||||||
|
#---------------------------------------------------
|
||||||
|
$(OBJ_DIR):
|
||||||
|
mkdir -p $(OBJ_DIR)
|
||||||
|
#---------------------------------------------------
|
||||||
|
clean:
|
||||||
|
@ rm -rf $(OBJ)
|
||||||
|
#---------------------------------------------------
|
|
@ -2,7 +2,7 @@
|
||||||
#define SIGNAL_H
|
#define SIGNAL_H
|
||||||
|
|
||||||
#define DEFAULT_SIGINT 2
|
#define DEFAULT_SIGINT 2
|
||||||
#define TIME_TO_RESET 30
|
#define TIME_TO_RESET 10
|
||||||
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "../inc/custom_signal.h"
|
#include <../inc/custom_signal.h>
|
||||||
|
|
||||||
void serverSigHandler(int sig) {
|
void serverSigHandler(int sig) {
|
||||||
static int sigint_count = DEFAULT_SIGINT;
|
static int sigint_count = DEFAULT_SIGINT;
|
||||||
|
@ -16,7 +18,7 @@ void serverSigHandler(int sig) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default: //SIGALRM
|
default: //SIGALRM
|
||||||
printf("<Server> Time to exit (%d s) expired", TIME_TO_RESET);
|
printf("<Server> Time to exit (%d sec) expired\n", TIME_TO_RESET);
|
||||||
sigint_count = DEFAULT_SIGINT;
|
sigint_count = DEFAULT_SIGINT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue