This commit is contained in:
Jack Halford 2017-03-27 03:12:24 +02:00
parent 6569be04bb
commit 3cb0450ea5
7 changed files with 35 additions and 17 deletions

View file

@ -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\

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);

View file

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* exec_reset.c :+: :+: :+: */
/* exec_destroy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 ;
}

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* jobc_destroy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/07 18:07:50 by jhalford #+# #+# */
/* Updated: 2017/03/27 00:36:29 by jhalford ### ########.fr */
/* Updated: 2017/03/27 03:11:57 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -26,6 +26,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);