pipelines fixed, job messaging better for notification & for builtin_jobs. still gotta fix cat (See previous commits msgs)

This commit is contained in:
Jack Halford 2017-01-09 16:26:54 +01:00
parent 204d5b9795
commit 153b9aec79
10 changed files with 20 additions and 54 deletions

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/27 20:29:56 by jhalford #+# #+# */
/* Updated: 2017/01/09 15:57:08 by jhalford ### ########.fr */
/* Updated: 2017/01/09 16:22:39 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/10 16:55:09 by jhalford #+# #+# */
/* Updated: 2017/01/09 14:05:43 by jhalford ### ########.fr */
/* Updated: 2017/01/09 16:23:37 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -52,7 +52,7 @@ void job_update_rank(void);
int do_job_notification(void);
void job_notify_new(t_job *job);
void job_notify_change(int id, int status);
void job_notify_change(int id);
void job_format(t_job *j, int rank[2], int opts);
void job_format_head(t_job *j, int rank[2]);
@ -71,7 +71,6 @@ void job_kill_all(void);
int put_job_in_foreground(t_job *job, int cont);
int put_job_in_background(t_job *job, int cont);
int job_cmp_pid(t_job *job, pid_t *pid);
int job_cmp_id(t_job *job, int *id);
void job_getrank(int (*rank)[2]);

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/28 14:28:41 by jhalford #+# #+# */
/* Updated: 2017/01/08 16:00:21 by jhalford ### ########.fr */
/* Updated: 2017/01/09 16:25:06 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/27 21:13:23 by jhalford #+# #+# */
/* Updated: 2017/01/09 15:56:40 by jhalford ### ########.fr */
/* Updated: 2017/01/09 16:19:38 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -39,7 +39,7 @@ int exec_pipe(t_btree **ast)
if (start)
p->attributes |= PROCESS_PIPESTART;
close(p->fdin);
close(fds[PIPE_READ]);
p->fdin = STDIN;
btree_delone(ast, &ast_free);
return (0);

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/15 17:43:01 by jhalford #+# #+# */
/* Updated: 2017/01/09 14:05:27 by jhalford ### ########.fr */
/* Updated: 2017/01/09 16:20:09 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/15 13:01:19 by jhalford #+# #+# */
/* Updated: 2017/01/08 14:00:23 by jhalford ### ########.fr */
/* Updated: 2017/01/09 16:24:22 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -26,17 +26,17 @@ int do_job_notification(void)
while (jlist)
{
j = jlist->content;
DG("checking job [%i]", j->id);
DG("checking [%i]", j->id);
if (job_is_completed(j->id))
{
ret = 1;
job_notify_change(j->id, 0);
job_notify_change(j->id);
job_remove(j->id);
}
else if (job_is_stopped(j->id) && !(j->attributes & JOB_NOTIFIED))
{
ret = 1;
job_notify_change(j->id, -1);
job_notify_change(j->id);
j->attributes |= JOB_NOTIFIED;
}
jlist = jlist->next;

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/08 15:36:56 by jhalford #+# #+# */
/* Updated: 2017/01/08 15:44:07 by jhalford ### ########.fr */
/* Updated: 2017/01/09 16:25:25 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,53 +6,20 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/12 15:04:03 by jhalford #+# #+# */
/* Updated: 2017/01/09 12:39:33 by jhalford ### ########.fr */
/* Updated: 2017/01/09 16:24:32 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "job_control.h"
void job_notify_change(int id, int status)
void job_notify_change(int id)
{
t_job *job;
t_jobc *jobc;
t_list *plist;
t_process *p;
char rank;
int rank[2];
rank = ' ';
jobc = &data_singleton()->jobc;
job = jobc->first_job->content;
if (id == job->id)
rank = '+';
else if (jobc->first_job->next)
{
job = jobc->first_job->next->content;
if (id == job->id)
rank = '-';
}
ft_printf("{mag}[%i] %c ", id, rank);
job = ft_lst_find(jobc->first_job, &id, job_cmp_id)->content;
if (status == -1)
ft_printf("{red}stopped{mag}");
else
{
plist = job->first_process;
p = ft_lstlast(job->first_process)->content;
if (p->status == 0)
ft_printf("{gre}done{mag}");
else
ft_printf("{red}exit %i{mag}", p->status);
}
ft_printf("\t ");
plist = job->first_process;
while (plist)
{
p = plist->content;
ft_sstrprint(p->av, ' ');
if (plist->next)
ft_printf(" |");
plist = plist->next;
}
ft_printf("{eoc}\n");
job_getrank(&rank);
job_format(job, rank, 0);
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/10 15:14:47 by jhalford #+# #+# */
/* Updated: 2017/01/09 15:59:05 by jhalford ### ########.fr */
/* Updated: 2017/01/09 16:16:20 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/12 17:37:04 by jhalford #+# #+# */
/* Updated: 2017/01/08 15:55:39 by jhalford ### ########.fr */
/* Updated: 2017/01/09 16:25:04 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -22,6 +22,6 @@ void shell_exit(void)
/* DG("cleanup. char * UP at %p", UP); */
/* DG("cleanup. char * BC at %p", BC); */
data_exit();
/* job_kill_all(); */
job_kill_all();
tcsetattr(0, TCSANOW, &data_singleton()->jobc.shell_tmodes);
}