diff --git a/42sh/Makefile b/42sh/Makefile index 957be2a2..7da7e17a 100644 --- a/42sh/Makefile +++ b/42sh/Makefile @@ -196,6 +196,7 @@ job_control/job_run.c\ job_control/job_update_id.c\ job_control/job_update_status.c\ job_control/job_wait.c\ +job_control/jobc_destroy.c\ job_control/mark_job_as_running.c\ job_control/pprint_brace.c\ job_control/pprint_case.c\ diff --git a/42sh/includes/job_control.h b/42sh/includes/job_control.h index ddf9e390..6d9a8b19 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: 2017/03/24 16:17:40 by gwojda ### ########.fr */ +/* Updated: 2017/03/27 03:11:08 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -35,6 +35,8 @@ struct s_jobc struct termios shell_tmodes; }; +int jobc_destroy(t_jobc *jobc); + t_list *job_getprocess(pid_t pid); int job_addprocess(t_process *p); void job_update_id(void); diff --git a/42sh/src/exec/exec_destroy.c b/42sh/src/exec/exec_destroy.c index e6e2b525..f1d7c764 100644 --- a/42sh/src/exec/exec_destroy.c +++ b/42sh/src/exec/exec_destroy.c @@ -1,12 +1,12 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* exec_reset.c :+: :+: :+: */ +/* exec_destroy.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ +/* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ -/* Created: 2017/03/08 14:31:42 by jhalford #+# #+# */ -/* Updated: 2017/03/27 00:33:31 by jhalford ### ########.fr */ +/* Created: 2017/03/27 03:09:58 by jhalford #+# #+# */ +/* Updated: 2017/03/27 03:10:37 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,14 +14,8 @@ int exec_destroy(t_exec *exec) { - t_jobc *jobc; - int i; - if (!exec) return (0); - jobc = &data_singleton()->jobc; ft_lstdel(&exec->op_stack, ft_lst_cfree); - ft_lstdel(&jobc->first_job, job_free); - i = -1; return (0); } diff --git a/42sh/src/exec/mark_process_status.c b/42sh/src/exec/mark_process_status.c index 15f1f223..d31a996a 100644 --- a/42sh/src/exec/mark_process_status.c +++ b/42sh/src/exec/mark_process_status.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/12 12:41:11 by jhalford #+# #+# */ -/* Updated: 2017/03/24 17:28:45 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 03:08:10 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -35,6 +35,6 @@ int mark_process_status(pid_t pid, int status) } return (0); } - SH_ERR("No child process %d", pid); + SH_ERR("No child process %i", pid); return (1); } diff --git a/42sh/src/job_control/job_update_status.c b/42sh/src/job_control/job_update_status.c index 8e89d64e..4467696e 100644 --- a/42sh/src/job_control/job_update_status.c +++ b/42sh/src/job_control/job_update_status.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/15 12:56:11 by jhalford #+# #+# */ -/* Updated: 2017/03/20 14:36:02 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 03:07:57 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,8 +21,8 @@ void job_update_status(void) { if ((pid = waitpid(WAIT_ANY, &status, WUNTRACED | WNOHANG)) == -1 && errno != ECHILD) - ft_dprintf(2, "{red}%s: waitpid error errno=%i{eoc}\n", - SHELL_NAME, errno); + SH_ERR("waitpid(): %s", strerror(errno)); + DG("wait trigger pid=%i", pid); if (pid <= 1 || mark_process_status(pid, status)) break ; } diff --git a/42sh/src/job_control/jobc_destroy.c b/42sh/src/job_control/jobc_destroy.c new file mode 100644 index 00000000..2f86df98 --- /dev/null +++ b/42sh/src/job_control/jobc_destroy.c @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* jobc_destroy.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/03/27 03:09:41 by jhalford #+# #+# */ +/* Updated: 2017/03/27 03:10:55 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "minishell.h" + +int jobc_destroy(t_jobc *jobc) +{ + if (jobc) + ft_lstdel(&jobc->first_job, job_free); + return (0); +} diff --git a/42sh/src/main/data_exit.c b/42sh/src/main/data_exit.c index 66d6494f..a012f2a7 100644 --- a/42sh/src/main/data_exit.c +++ b/42sh/src/main/data_exit.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/07 18:07:50 by jhalford #+# #+# */ -/* Updated: 2017/03/27 02:55:04 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 03:12:52 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -25,6 +25,7 @@ void data_exit(void) lexer_destroy(&data->lexer); parser_destroy(&data->parser); exec_destroy(&data->exec); + jobc_destroy(&data->jobc); i = -1; while (++i < 10) ft_lstdel(&data->exec.fd_save[i], ft_lst_cfree);