yeay
This commit is contained in:
commit
aba3713a04
17 changed files with 53 additions and 58 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/10 16:55:09 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/15 20:31:07 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/17 23:10:35 by wescande ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -42,7 +42,7 @@ void job_update_id(void);
|
|||
void job_update_rank(void);
|
||||
|
||||
int do_job_notification(void);
|
||||
void job_notify_new(t_job *job);
|
||||
void job_notify_new(int id);
|
||||
void job_notify_change(int id);
|
||||
void job_format(t_job *j, int opts);
|
||||
void job_format_head(t_job *j);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/07 13:49:04 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/15 20:51:55 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/17 21:30:29 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/07 13:33:27 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/14 20:24:44 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/17 21:33:37 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/13 13:09:57 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/17 19:51:06 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/17 23:33:54 by wescande ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -37,7 +37,6 @@ t_execf *is_builtin(t_process *p)
|
|||
{
|
||||
int i;
|
||||
|
||||
DG("in builtin");
|
||||
i = -1;
|
||||
while (g_builtin[++i].name)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/*ss ************************************************************************** */
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* exec_leaf.c :+: :+: :+: */
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/07 15:47:30 by wescande #+# #+# */
|
||||
/* Updated: 2017/03/16 21:45:47 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/17 23:10:43 by wescande ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -45,6 +45,8 @@ int exec_leaf(t_btree **ast)
|
|||
{
|
||||
if (JOB_IS_FG(job->attrs))
|
||||
put_job_in_foreground(job, 0);
|
||||
else
|
||||
job_notify_new(job->id);
|
||||
job->pgid = 0;
|
||||
}
|
||||
DG("check");
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/12 12:41:11 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/17 22:55:09 by wescande ### ########.fr */
|
||||
/* Updated: 2017/03/18 00:04:46 by wescande ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -19,23 +19,21 @@ int mark_process_status(pid_t pid, int status)
|
|||
|
||||
if ((plist = job_getprocess(pid)))
|
||||
{
|
||||
DG("#######################");
|
||||
p = plist->content;
|
||||
p->status = status;
|
||||
if (WIFSTOPPED(status))
|
||||
{
|
||||
DG("#######################");
|
||||
p->attrs &= ~PROCESS_STATE_MASK;
|
||||
p->attrs |= PROCESS_SUSPENDED;
|
||||
}
|
||||
else
|
||||
{
|
||||
DG("#######################");
|
||||
p->attrs &= ~PROCESS_STATE_MASK;
|
||||
p->attrs |= PROCESS_COMPLETED;
|
||||
if (WIFSIGNALED(status) && DEBUG_MODE)
|
||||
ft_printf("{mag}%d: Terminated by signal %d.\n{eoc}",
|
||||
(int)pid, WTERMSIG(status));
|
||||
if (WIFSIGNALED(status))
|
||||
psignal(WTERMSIG(status), NULL);
|
||||
/* ft_printf("{mag}%d: Terminated by signal %d.\n{eoc}", */
|
||||
/* (int)pid, WTERMSIG(status)); */
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/13 22:21:19 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/17 22:49:31 by wescande ### ########.fr */
|
||||
/* Updated: 2017/03/17 23:49:43 by wescande ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -35,12 +35,6 @@ int do_the_muther_forker(t_process *p)
|
|||
else if (pid)
|
||||
return (pid);
|
||||
DG("START OF FORK");
|
||||
signal(SIGINT, SIG_DFL);
|
||||
signal(SIGQUIT, SIG_DFL);
|
||||
signal(SIGTSTP, SIG_DFL);
|
||||
signal(SIGTTIN, SIG_DFL);
|
||||
signal(SIGTTOU, SIG_DFL);
|
||||
signal(SIGCHLD, SIG_DFL);
|
||||
if (process_redirect(p))
|
||||
exit (1);
|
||||
process_setgroup(p, 0);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/13 17:48:10 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/16 13:54:18 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/18 00:23:57 by wescande ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -26,7 +26,8 @@ int process_setgroup(t_process *p, pid_t pid)
|
|||
DG("setpgid(%i, %i)", pid, j->pgid);
|
||||
if (setpgid(pid, j->pgid) == -1)
|
||||
ft_dprintf(2, "{red}%s: internal setpgid() errno=%i{eoc}\n", SHELL_NAME, errno);
|
||||
if (pid == 0 && JOB_IS_FG(j->attrs))
|
||||
/* if (JOB_IS_FG(j->attrs)) */
|
||||
if (pid ==0 && JOB_IS_FG(j->attrs))
|
||||
{
|
||||
DG("tcsetpgrp[%i]", j->pgid);
|
||||
tcsetpgrp(STDIN, j->pgid);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/11 14:08:35 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/11 14:08:37 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/18 00:16:37 by wescande ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -14,12 +14,10 @@
|
|||
|
||||
void process_setsig(void)
|
||||
{
|
||||
/* signal(SIGINT, SIG_DFL); */
|
||||
signal(SIGINT, SIG_DFL);
|
||||
signal(SIGQUIT, SIG_DFL);
|
||||
signal(SIGTSTP, SIG_DFL);
|
||||
signal(SIGTTIN, SIG_DFL);
|
||||
signal(SIGTTOU, SIG_DFL);
|
||||
/* signal(SIGTTIN, sigttin_handler); */
|
||||
/* signal(SIGTTOU, sigttou_handler); */
|
||||
signal(SIGCHLD, SIG_DFL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/15 13:01:19 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/17 22:53:45 by wescande ### ########.fr */
|
||||
/* Updated: 2017/03/18 00:07:12 by wescande ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -27,19 +27,14 @@ int do_job_notification(void)
|
|||
{
|
||||
j = jlist->content;
|
||||
jlist = jlist->next;
|
||||
DG();
|
||||
if (job_is_completed(j->id))
|
||||
DG();
|
||||
if (job_is_completed(j->id)
|
||||
|| (job_is_stopped(j->id) && !(j->attrs & JOB_NOTIFIED)))
|
||||
{
|
||||
DG();
|
||||
ret = 1;
|
||||
job_notify_change(j->id);
|
||||
j->attrs |= JOB_NOTIFIED;
|
||||
job_remove(j->id);
|
||||
}
|
||||
DG();
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/13 13:54:51 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/16 22:23:24 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/17 23:06:08 by wescande ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ int job_addprocess(t_process *p)
|
|||
}
|
||||
job = jobc->first_job->content;
|
||||
ft_lsteadd(&job->first_process, ft_lstnew(p, sizeof(*p)));
|
||||
if (JOB_IS_BG(job->attrs) && IS_PIPEEND(*p))
|
||||
job_notify_new(job);
|
||||
/* if (JOB_IS_BG(job->attrs) && IS_PIPEEND(*p)) */
|
||||
/* job_notify_new(job); */
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,19 +6,25 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/13 14:27:01 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/10 15:36:10 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/17 23:10:47 by wescande ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
void job_notify_new(t_job *job)
|
||||
void job_notify_new(int id)
|
||||
{
|
||||
t_list *plist;
|
||||
t_process *p;
|
||||
t_jobc *jobc;
|
||||
t_job *job;
|
||||
|
||||
ft_printf("{mag}[%i]", job->id);
|
||||
jobc = &data_singleton()->jobc;
|
||||
if (!(plist = ft_lst_find(jobc->first_job, &id, job_cmp_id)))
|
||||
return ;
|
||||
job = plist->content;
|
||||
plist = job->first_process;
|
||||
ft_printf("{mag}[%i]", job->id);
|
||||
while (plist)
|
||||
{
|
||||
p = plist->content;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/09 13:05:55 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/16 16:41:10 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/17 21:35:27 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -34,27 +34,32 @@ static int redirection_print(t_redir *redir)
|
|||
|
||||
static void process_format_state(t_process *p)
|
||||
{
|
||||
int state;
|
||||
int state;
|
||||
char *statestr;
|
||||
|
||||
state = p->attrs & PROCESS_STATE_MASK;
|
||||
statestr = NULL;
|
||||
if (state == PROCESS_RUNNING)
|
||||
ft_putstr("running ");
|
||||
ft_asprintf(&statestr, "running");
|
||||
else if (state == PROCESS_SUSPENDED)
|
||||
ft_putstr("suspended");
|
||||
ft_asprintf(&statestr, "suspended");
|
||||
else if (state == PROCESS_CONTINUED)
|
||||
{
|
||||
ft_putstr("continued");
|
||||
ft_asprintf(&statestr, "continued");
|
||||
p->attrs &= ~PROCESS_STATE_MASK;
|
||||
p->attrs |= PROCESS_RUNNING;
|
||||
}
|
||||
else if (state == PROCESS_COMPLETED)
|
||||
{
|
||||
if (p->status == 0)
|
||||
ft_putstr("done ");
|
||||
if (WIFSIGNALED(p->status))
|
||||
ft_asprintf(&statestr, strsignal(WTERMSIG(p->status)));
|
||||
else if (p->status == 0)
|
||||
ft_asprintf(&statestr, "done");
|
||||
else
|
||||
ft_printf("exit %i ", p->status);
|
||||
ft_asprintf(&statestr, "%s %i", "exit", WEXITSTATUS(p->status));
|
||||
}
|
||||
ft_putchar('\t');
|
||||
ft_printf("%-*s\t", 12, statestr);
|
||||
ft_strdel(&statestr);
|
||||
}
|
||||
|
||||
static void process_format_com_long(t_list **plist)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/10 17:37:56 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/17 22:39:21 by wescande ### ########.fr */
|
||||
/* Updated: 2017/03/18 00:05:39 by wescande ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
void sigchld_handler(int signo)
|
||||
{
|
||||
DG("<<<<<<<<<<<<<<<<<<<<<<<<<<<");
|
||||
do_job_notification();
|
||||
//do_job_notification();dynamic notif ???
|
||||
(void)signo;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/13 13:51:33 by gwojda #+# #+# */
|
||||
/* Updated: 2017/03/17 22:41:13 by wescande ### ########.fr */
|
||||
/* Updated: 2017/03/18 00:14:42 by wescande ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -107,9 +107,7 @@ void ft_prompt(void)
|
|||
ft_printf("\x1b[38;5;10m➜ ");
|
||||
ft_putstr("\x1b[38;5;361m");
|
||||
ret += ft_currend_dir();
|
||||
signal(SIGCHLD, SIG_DFL);
|
||||
ret += ft_git_status();
|
||||
signal(SIGCHLD, sigchld_handler);
|
||||
ft_putstr("\033[22;37m");
|
||||
data_singleton()->line.prompt_size = ret + 4;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/17 21:16:25 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/17 21:18:44 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/12 17:23:59 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/17 22:38:39 by wescande ### ########.fr */
|
||||
/* Updated: 2017/03/18 00:04:33 by wescande ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ static int interactive_settings(void)
|
|||
signal(SIGTSTP, SIG_IGN);
|
||||
signal(SIGTTIN, SIG_IGN);
|
||||
signal(SIGTTOU, SIG_IGN);
|
||||
signal(SIGCHLD, sigchld_handler);
|
||||
signal(SIGCHLD, SIG_DFL);//sigchld_handler); TBC IF dynamic notification are wanted
|
||||
*shell_pgid = getpid();
|
||||
if (setpgid(*shell_pgid, *shell_pgid))
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue