diff --git a/bin/command (1).o b/bin/command (1).o deleted file mode 100644 index 239673b009e51924681a37137047349cd5eb7be9..0000000000000000000000000000000000000000 Binary files a/bin/command (1).o and /dev/null differ diff --git a/bin/command.h b/bin/command.h index 2bed089193d712de6c863936ec0ed4f485bb1f9b..878af9596006f577ef5928b6fc430004ad4793ac 100644 --- a/bin/command.h +++ b/bin/command.h @@ -22,11 +22,17 @@ void exec_builtin(char** argv, int argc); //IN: // cmd: struct countaining the command to be executed // foreground: if the task has to be run in foreground or background ('&' sign) +// pid_job : A pointer used to indicate to our shell which program is running currently +// +// pid_job must be initialized to 0 before use. void exec_job(cmd_t *cmd, bool foreground, pid_t* pid_job); // Execute a parsed pipe command as job (forks process) //IN: // cmd: struct countaining the commands to be executed and piped together // [UNUSED !!!] foreground: if the task has to be run in foreground or background ('&' sign) +// pid_job : A pointer used to indicate to our shell which program is running currently +// +// pid_job must be initialized to 0 before use. void exec_job_piped(cmd_t *cmd, bool foreground, pid_t* pid_job); #endif \ No newline at end of file diff --git a/bin/interface (1).o b/bin/interface (1).o deleted file mode 100644 index bfe355d92285f125b6135527ec2e0eaead013b4f..0000000000000000000000000000000000000000 Binary files a/bin/interface (1).o and /dev/null differ diff --git a/bin/interface.h b/bin/interface.h index 6144f66eb9d2a114ec52603c8ee1532f23c10775..70948ae06ed5ca0b1f7ce96d2a750c97e46cd86c 100644 --- a/bin/interface.h +++ b/bin/interface.h @@ -38,7 +38,9 @@ int ask_user_input(char* user_input); // cmd: the command to dispose of void dispose_command(cmd_t *cmd); -//Print command for debugging +// Print command for debugging +//IN: +// cmd: the command to print out void print_command(cmd_t cmd); #endif diff --git a/bin/main.c b/bin/main.c index 293f5a9649058a98a4acd53f94751e3ca549451d..d1ba41a0cb6b9ad7358f1133bf6d6a154f0cff44 100644 --- a/bin/main.c +++ b/bin/main.c @@ -16,6 +16,12 @@ // Stores the PID of the current foreground job int MAIN_JOB_PID = 0; + +// Catch the SIGCHILD signal and handle background processes +//IN: +// signal: [unused] +// +// This function must be used as a handler using the sigaction syscall void sigchld_handler(int signal) { int status; @@ -32,11 +38,23 @@ void sigchld_handler(int signal) } } + +// Terminate the shell and its subprocesses cleanly when we catch a SIGHUP signal. +//IN: +// signum: [unused] +// +// This function is designed to be used as an handler for the sighup signal : use the signal() syscall. void sighup(int signum) { exit(EXIT_SUCCESS); } +// Redirects a signal to the main job. +//IN: +// signum: the type of signal to be redirected to the main job, in our case sigint +// +// This function is designed to be used as an handler for signals : use the signal() syscall. +// In our case, we will use it to redirect the SIGINT signal to our main job process. void sigint_job(int signum) { if (MAIN_JOB_PID) @@ -46,6 +64,9 @@ void sigint_job(int signum) } } + + + int main(int argc, char *const argv[]) { printf(BOLDCYAN "Welcome to WaffleShell (#sh), use at your own risk !\n" RESET); diff --git a/bin/prettycolors.h b/bin/prettycolors.h index c5816d04255799fa9e70ec64f56f36feb9aa01a6..177905a8eebade8d931890ac1399b44558514304 100644 --- a/bin/prettycolors.h +++ b/bin/prettycolors.h @@ -1,3 +1,4 @@ +// LIST OF COLORS AVAILABLE TO OUR TERMINAL #define RESET "\033[0m" #define BLACK "\033[30m" /* Black */ #define RED "\033[31m" /* Red */