mini algo test pour traduire char en signale ok

This commit is contained in:
hugogogo
2021-08-28 14:03:20 +02:00
parent 737ce47555
commit 48c68624f0
6 changed files with 38 additions and 4 deletions

View File

@@ -1,10 +1,24 @@
#include "../includes/minitalk.h"
#include <stdlib.h> //for atoi
int main(int ac, char **av)
int usage(void)
{
if (ac != 2)
return (0);
kill(atoi(av[1]), SIGUSR1);
ft_printf("usage: ./client [server pid] [message]\n");
return (0);
}
void send_message(int server_pid, char *msg)
{
if (!ft_strcmp(msg, "SIGUSR1"))
kill(server_pid, SIGUSR1);
if (!ft_strcmp(msg, "SIGUSR2"))
kill(server_pid, SIGUSR2);
}
int main(int ac, char **av)
{
if (ac != 3)
return (usage());
send_message(ft_atoi(av[1]), av[2]);
return (0);
}