tricks trick

This commit is contained in:
wescande 2017-03-17 22:56:41 +01:00
parent 26d660fd72
commit 9078573edc
7 changed files with 27 additions and 14 deletions

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/12 12:41:11 by jhalford #+# #+# */
/* Updated: 2017/03/16 23:00:36 by jhalford ### ########.fr */
/* Updated: 2017/03/17 22:55:09 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
@ -19,15 +19,18 @@ 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)

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/13 22:21:19 by jhalford #+# #+# */
/* Updated: 2017/03/17 20:31:20 by wescande ### ########.fr */
/* Updated: 2017/03/17 22:49:31 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
@ -34,19 +34,20 @@ 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);
data_singleton()->opts &= ~SH_INTERACTIVE;
data_singleton()->opts &= ~SH_OPTS_JOBC;
if (process_redirect(p))
exit (1);
process_setgroup(p, 0);
process_setsig();
exec_reset();
data_singleton()->opts &= ~SH_INTERACTIVE;
data_singleton()->opts &= ~SH_OPTS_JOBC;
exit(p->map.launch(p));
}
@ -63,7 +64,7 @@ int process_launch(t_process *p)
process_resetfds(p);
return (1);
}
DG("launcher forked!");
DG("launcher forked! with : %d ", pid);
p->pid = pid;
process_setgroup(p, pid);
if (p->fdin != STDIN)

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/15 13:01:19 by jhalford #+# #+# */
/* Updated: 2017/03/16 18:35:01 by jhalford ### ########.fr */
/* Updated: 2017/03/17 22:53:45 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
@ -27,15 +27,19 @@ 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;
if (job_is_completed(j->id))
job_remove(j->id);
job_remove(j->id);
}
DG();
}
return (ret);
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/12 15:04:03 by jhalford #+# #+# */
/* Updated: 2017/03/08 17:18:20 by jhalford ### ########.fr */
/* Updated: 2017/03/17 22:51:40 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
@ -19,5 +19,6 @@ void job_notify_change(int id)
jobc = &data_singleton()->jobc;
job = ft_lst_find(jobc->first_job, &id, job_cmp_id)->content;
job_format(job, JOBS_OPTS_L);
if (job->attrs & JOB_BG)
job_format(job, JOBS_OPTS_L);
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/10 17:37:56 by jhalford #+# #+# */
/* Updated: 2017/03/08 17:21:34 by jhalford ### ########.fr */
/* Updated: 2017/03/17 22:39:21 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,5 +14,7 @@
void sigchld_handler(int signo)
{
DG("<<<<<<<<<<<<<<<<<<<<<<<<<<<");
do_job_notification();
(void)signo;
}

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/13 13:51:33 by gwojda #+# #+# */
/* Updated: 2017/03/16 16:43:35 by gwojda ### ########.fr */
/* Updated: 2017/03/17 22:41:13 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
@ -107,7 +107,9 @@ 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;
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/12 17:23:59 by jhalford #+# #+# */
/* Updated: 2017/03/17 21:18:15 by wescande ### ########.fr */
/* Updated: 2017/03/17 22:38:39 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, SIG_IGN);
signal(SIGCHLD, sigchld_handler);
*shell_pgid = getpid();
if (setpgid(*shell_pgid, *shell_pgid))
{