diff --git a/42sh/includes/job_control.h b/42sh/includes/job_control.h index 7e42ea6f..a9a3d333 100644 --- a/42sh/includes/job_control.h +++ b/42sh/includes/job_control.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/10 16:55:09 by jhalford #+# #+# */ -/* Updated: 2016/12/10 17:36:55 by jhalford ### ########.fr */ +/* Updated: 2016/12/10 18:20:40 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -24,7 +24,13 @@ struct s_job char *command; }; +extern t_data *g_data; + void job_new(t_data *data, char **av, pid_t pid); void job_announce(t_job *job); +void sigchld_handler(int signo); +void sigint_handler(int signo); +void sigtstp_handler(int signo); + #endif diff --git a/42sh/includes/minishell.h b/42sh/includes/minishell.h index ef76d26c..2f9aaae6 100644 --- a/42sh/includes/minishell.h +++ b/42sh/includes/minishell.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/10 13:07:44 by jhalford #+# #+# */ -/* Updated: 2016/12/10 17:12:35 by jhalford ### ########.fr */ +/* Updated: 2016/12/10 17:56:39 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -76,8 +76,6 @@ typedef enum e_qstate t_qstate; extern t_stof g_builtins[]; extern pid_t g_pid; -void sigint_handler(int signo); -void sigstop_handler(int signo); int data_init(t_data *data); void data_exit(t_data *data); void ft_cleanup(void); diff --git a/42sh/libft b/42sh/libft index 97bc4fed..42e1a190 160000 --- a/42sh/libft +++ b/42sh/libft @@ -1 +1 @@ -Subproject commit 97bc4fed552dce523e2de8fb744ba46ec877f8eb +Subproject commit 42e1a190bd86ea288ee9a367fefeac8284a67cf4 diff --git a/42sh/src/job-control/job_new.c b/42sh/src/job-control/job_new.c index e9fd72b8..28142202 100644 --- a/42sh/src/job-control/job_new.c +++ b/42sh/src/job-control/job_new.c @@ -6,13 +6,13 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/10 16:51:54 by jhalford #+# #+# */ -/* Updated: 2016/12/10 17:37:33 by jhalford ### ########.fr */ +/* Updated: 2016/12/10 17:58:04 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ #include "job_control.h" -void job_new(t_data *data, char **av, pid_t pid, t_type type) +void job_new(t_data *data, char **av, pid_t pid) { t_job job; diff --git a/42sh/src/job-control/sigchld_handler.c b/42sh/src/job-control/sigchld_handler.c index fd0b3e0e..5df1e708 100644 --- a/42sh/src/job-control/sigchld_handler.c +++ b/42sh/src/job-control/sigchld_handler.c @@ -6,14 +6,26 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/10 17:37:56 by jhalford #+# #+# */ -/* Updated: 2016/12/10 17:46:12 by jhalford ### ########.fr */ +/* Updated: 2016/12/10 18:25:01 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ #include "minishell.h" +t_data *g_data; + void sigchld_handler(int signo) { + t_job *job; + t_list *list; + (void)signo; DG("got SIGCHLD"); + list = g_data->jobc.list; + if (list) + job = list->content; + else + job = NULL; + if (job) + DG("job pid=%i", job->pid); } diff --git a/42sh/src/job-control/sigtstp_handler.c b/42sh/src/job-control/sigtstp_handler.c index 7475ed07..95814e84 100644 --- a/42sh/src/job-control/sigtstp_handler.c +++ b/42sh/src/job-control/sigtstp_handler.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/10 15:14:53 by jhalford #+# #+# */ -/* Updated: 2016/12/10 17:46:16 by jhalford ### ########.fr */ +/* Updated: 2016/12/10 18:20:57 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/main/data_init.c b/42sh/src/main/data_init.c index 9b549e58..fe10e2bb 100644 --- a/42sh/src/main/data_init.c +++ b/42sh/src/main/data_init.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */ -/* Updated: 2016/12/10 17:35:16 by jhalford ### ########.fr */ +/* Updated: 2016/12/10 17:58:36 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -39,5 +39,6 @@ int data_init(t_data *data) if (signal(SIGTSTP, sigtstp_handler) == SIG_ERR) ft_dprintf(STDERR, "\ncan't catch SIGTSTP\n"); if (signal(SIGCHLD, sigchld_handler) == SIG_ERR) + ft_dprintf(STDERR, "\ncan't catch SIGCHLD\n"); return (0); } diff --git a/42sh/src/main/main.c b/42sh/src/main/main.c index 1a8a70be..28044585 100644 --- a/42sh/src/main/main.c +++ b/42sh/src/main/main.c @@ -6,12 +6,14 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */ -/* Updated: 2016/12/10 17:16:19 by jhalford ### ########.fr */ +/* Updated: 2016/12/10 17:58:39 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ #include "minishell.h" +t_data *g_data; + int main(void) { t_data data; @@ -20,6 +22,7 @@ int main(void) token = NULL; ast = NULL; + g_data = &data; if (data_init(&data)) return (1); DG("{inv}{bol}{gre}start of shell");