makefile ok and client receive sigusr
This commit is contained in:
6
Makefile
6
Makefile
@@ -15,7 +15,8 @@ ODIR = ./builds
|
|||||||
S_OBJS = $(S_SRCS:%.c=$(ODIR)/%.o)
|
S_OBJS = $(S_SRCS:%.c=$(ODIR)/%.o)
|
||||||
C_OBJS = $(C_SRCS:%.c=$(ODIR)/%.o)
|
C_OBJS = $(C_SRCS:%.c=$(ODIR)/%.o)
|
||||||
|
|
||||||
DEPS = ./includes/minitalk.h
|
DEPS = ./includes/minitalk.h \
|
||||||
|
./libft/includes/libft.h
|
||||||
IDIR = $(dir $(DEPS))
|
IDIR = $(dir $(DEPS))
|
||||||
# $(dir PATH/TO/FILE) expands to "PATH/TO/" -> the directory of a file
|
# $(dir PATH/TO/FILE) expands to "PATH/TO/" -> the directory of a file
|
||||||
|
|
||||||
@@ -25,7 +26,7 @@ LIBS = $(_LIBS:lib%.a=%)
|
|||||||
|
|
||||||
CFLAGS = $(IDIR:%=-I%)
|
CFLAGS = $(IDIR:%=-I%)
|
||||||
CFLAGS += -g3 -Wall -Wextra -Werror
|
CFLAGS += -g3 -Wall -Wextra -Werror
|
||||||
LFLAGS = -L$(LDIR) -l$(LIBS)
|
LFLAGS = -L./libft -lft
|
||||||
|
|
||||||
|
|
||||||
# - - - - - - - - - - - - - - # target: prerequisites | $@ : target
|
# - - - - - - - - - - - - - - # target: prerequisites | $@ : target
|
||||||
@@ -35,6 +36,7 @@ LFLAGS = -L$(LDIR) -l$(LIBS)
|
|||||||
all: libft $(SERVER) $(CLIENT)
|
all: libft $(SERVER) $(CLIENT)
|
||||||
|
|
||||||
libft:
|
libft:
|
||||||
|
@echo "hello"
|
||||||
make -C $(LDIR)
|
make -C $(LDIR)
|
||||||
|
|
||||||
$(SERVER): $(S_OBJS) $(DEPS)
|
$(SERVER): $(S_OBJS) $(DEPS)
|
||||||
|
|||||||
BIN
builds/client.o
Normal file
BIN
builds/client.o
Normal file
Binary file not shown.
BIN
builds/server.o
Normal file
BIN
builds/server.o
Normal file
Binary file not shown.
@@ -1,9 +1,9 @@
|
|||||||
#ifndef FT_PRINTF_H
|
#ifndef MINITALK_H
|
||||||
# define FT_PRINTF_H
|
# define MINITALK_H
|
||||||
|
|
||||||
# include <signal.h> // for signal kill
|
# include <signal.h> // for signal kill
|
||||||
# include <sys/types.h> // for getpid kill
|
# include <sys/types.h> // for getpid kill
|
||||||
# include <unistd.h> // for getpid
|
# include <unistd.h> // for getpid
|
||||||
|
# include "libft.h"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
1
libft
1
libft
Submodule libft deleted from c335eb1f6a
148
srcs/server.c
148
srcs/server.c
@@ -1,9 +1,16 @@
|
|||||||
#include "../includes/minitalk.h"
|
#include "minitalk.h"
|
||||||
#include <stdio.h> // for printf
|
#include <stdio.h> // for printf
|
||||||
|
|
||||||
void put_client_pid(int client_pid)
|
//int ft_printf(char *string, ...);
|
||||||
|
|
||||||
|
void sig_handler_1(int sig_num)
|
||||||
{
|
{
|
||||||
printf("%i\n", client_pid);
|
ft_printf("SIGUSR1 %i\n", sig_num);
|
||||||
|
}
|
||||||
|
|
||||||
|
void sig_handler_2(int sig_num)
|
||||||
|
{
|
||||||
|
ft_printf("SIGUSR2 %i\n", sig_num);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
@@ -11,8 +18,9 @@ int main()
|
|||||||
int pid;
|
int pid;
|
||||||
|
|
||||||
pid = (int)getpid();
|
pid = (int)getpid();
|
||||||
printf("%i\n", pid);
|
ft_printf("%i\n", pid);
|
||||||
signal(SIGUSR1, put_client_pid);
|
signal(SIGUSR1, sig_handler_1);
|
||||||
|
signal(SIGUSR2, sig_handler_2);
|
||||||
while (1);
|
while (1);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@@ -37,4 +45,134 @@ int main()
|
|||||||
** you can only use two signals :
|
** you can only use two signals :
|
||||||
** - SIGUSR1
|
** - SIGUSR1
|
||||||
** - SIGUSR2
|
** - SIGUSR2
|
||||||
|
**
|
||||||
|
** 1 000 0
|
||||||
|
** 2 001 1 2
|
||||||
|
** 3 002 10
|
||||||
|
** 4 003 11 2
|
||||||
|
** 5 004 100
|
||||||
|
** 6 005 101
|
||||||
|
** 7 006 110
|
||||||
|
** 8 007 111 4
|
||||||
|
** 9 008 1000
|
||||||
|
** 10 009 1001
|
||||||
|
** 11 010 1010
|
||||||
|
** 12 011 1011
|
||||||
|
** 13 012 1100
|
||||||
|
** 14 013 1101
|
||||||
|
** 15 014 1110
|
||||||
|
** 16 015 1111 8
|
||||||
|
** 17 016 10000
|
||||||
|
** 18 017 10001
|
||||||
|
** 19 018 10010
|
||||||
|
** 20 019 10011
|
||||||
|
** 21 020 10100
|
||||||
|
** 22 021 10101
|
||||||
|
** 23 022 10110
|
||||||
|
** 24 023 10111
|
||||||
|
** 25 024 11000
|
||||||
|
** 26 025 11001
|
||||||
|
** 27 026 11010
|
||||||
|
** 28 027 11011
|
||||||
|
** 29 028 11100
|
||||||
|
** 30 029 11101
|
||||||
|
** 31 030 11110
|
||||||
|
** 32 031 11111 16
|
||||||
|
** 33 032 100000
|
||||||
|
** 34 033 100001
|
||||||
|
** 35 034 100010
|
||||||
|
** 36 035 100011
|
||||||
|
** 37 036 100100
|
||||||
|
** 38 037 100101
|
||||||
|
** 39 038 100110
|
||||||
|
** 40 039 100111
|
||||||
|
** 41 040 101000
|
||||||
|
** 42 041 101001
|
||||||
|
** 43 042 101010
|
||||||
|
** 44 043 101011
|
||||||
|
** 45 044 101100
|
||||||
|
** 46 045 101101
|
||||||
|
** 47 046 101110
|
||||||
|
** 48 047 101111
|
||||||
|
** 49 048 110000
|
||||||
|
** 50 049 110001
|
||||||
|
** 51 050 110010
|
||||||
|
** 52 051 110011
|
||||||
|
** 53 052 110100
|
||||||
|
** 54 053 110101
|
||||||
|
** 55 054 110110
|
||||||
|
** 56 055 110111
|
||||||
|
** 57 056 111000
|
||||||
|
** 58 057 111001
|
||||||
|
** 59 058 111010
|
||||||
|
** 60 059 111011
|
||||||
|
** 61 060 111100
|
||||||
|
** 62 061 111101
|
||||||
|
** 63 062 111110
|
||||||
|
** 64 063 111111 32
|
||||||
|
** 65 064 1000000
|
||||||
|
** 66 065 1000001
|
||||||
|
** 67 066 1000010
|
||||||
|
** 68 067 1000011
|
||||||
|
** 69 068 1000100
|
||||||
|
** 70 069 1000101
|
||||||
|
** 71 070 1000110
|
||||||
|
** 72 071 1000111
|
||||||
|
** 73 072 1001000
|
||||||
|
** 74 073 1001001
|
||||||
|
** 75 074 1001010
|
||||||
|
** 76 075 1001011
|
||||||
|
** 77 076 1001100
|
||||||
|
** 78 077 1001101
|
||||||
|
** 79 078 1001110
|
||||||
|
** 80 079 1001111
|
||||||
|
** 81 080 1010000
|
||||||
|
** 82 081 1010001
|
||||||
|
** 83 082 1010010
|
||||||
|
** 84 083 1010011
|
||||||
|
** 85 084 1010100
|
||||||
|
** 86 085 1010101
|
||||||
|
** 87 086 1010110
|
||||||
|
** 88 087 1010111
|
||||||
|
** 89 088 1011000
|
||||||
|
** 90 089 1011001
|
||||||
|
** 91 090 1011010
|
||||||
|
** 92 091 1011011
|
||||||
|
** 93 092 1011100
|
||||||
|
** 94 093 1011101
|
||||||
|
** 95 094 1011110
|
||||||
|
** 96 095 1011111
|
||||||
|
** 97 096 1100000
|
||||||
|
** 98 097 1100001
|
||||||
|
** 99 098 1100010
|
||||||
|
** 100 099 1100011
|
||||||
|
** 101 100 1100100
|
||||||
|
** 102 101 1100101
|
||||||
|
** 103 102 1100110
|
||||||
|
** 104 103 1100111
|
||||||
|
** 105 104 1101000
|
||||||
|
** 106 105 1101001
|
||||||
|
** 107 106 1101010
|
||||||
|
** 108 107 1101011
|
||||||
|
** 109 108 1101100
|
||||||
|
** 110 109 1101101
|
||||||
|
** 111 110 1101110
|
||||||
|
** 112 111 1101111
|
||||||
|
** 113 112 1110000
|
||||||
|
** 114 113 1110001
|
||||||
|
** 115 114 1110010
|
||||||
|
** 116 115 1110011
|
||||||
|
** 117 116 1110100
|
||||||
|
** 118 117 1110101
|
||||||
|
** 119 118 1110110
|
||||||
|
** 120 119 1110111
|
||||||
|
** 121 120 1111000
|
||||||
|
** 122 121 1111001
|
||||||
|
** 123 122 1111010
|
||||||
|
** 124 123 1111011
|
||||||
|
** 125 124 1111100
|
||||||
|
** 126 125 1111101
|
||||||
|
** 127 126 1111110
|
||||||
|
** 128 127 1111111 64
|
||||||
|
**
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user