Skip to content
Snippets Groups Projects
Commit a28f6d1a authored by julien.seemulle's avatar julien.seemulle :cowboy:
Browse files

Adding comments

parent 010e7a12
No related branches found
No related tags found
No related merge requests found
File deleted
......@@ -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
File deleted
......@@ -39,6 +39,8 @@ int ask_user_input(char* user_input);
void dispose_command(cmd_t *cmd);
// Print command for debugging
//IN:
// cmd: the command to print out
void print_command(cmd_t cmd);
#endif
......@@ -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);
......
// LIST OF COLORS AVAILABLE TO OUR TERMINAL
#define RESET "\033[0m"
#define BLACK "\033[30m" /* Black */
#define RED "\033[31m" /* Red */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment