Hello, guys.
I have to make a task scheduler in c in which on of his processes is a process called task_scheduler should be run in the terminal command using the following syntax:
task_scheduler <hh:mm> <n> <task_name>
So, here is what i did until now. I created a file called task_scheduler.c:
#include "scanner.h"//Validates the format of the parameters coming from the terminal. Works fine.
#include "tasks.h"//Linked list where tasks are scheduled. Woks fine.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char *argv[]) {
List *list = NULL;
int status;
daemon(1, 1);//To leave the terminal free so i can use to schedule a new task, but it doesn't work properly.
//Continue if there are four arguments coming from terminal except the first.
if( (argc-1) == 3 ) {
if( timer( argv[1] ) && amount( argv[2] ) ) {
printf("Parameters accepted.\n");
list = addTask( list, argv[1], argv[2], argv[3] );
}
}
else {
printf("Parameters not accepted.\n");
return 1;
}
return 0;
}
Everything works fine in this code, but i can add only one task! If i enter in terminal:
./task_scheduler 12:12 34 anything
./task_scheduler 23:34 56 lolololol
only one task is added! The second task is added in a new instance of task_scheduler and this is not what i want!