gotta fix problem with env
This commit is contained in:
parent
40378fec73
commit
6144e4eab5
8 changed files with 32 additions and 22 deletions
|
|
@ -59,7 +59,7 @@ void job_update_rank(void);
|
||||||
|
|
||||||
int do_job_notification(void);
|
int do_job_notification(void);
|
||||||
void job_notify_new(t_job *job);
|
void job_notify_new(t_job *job);
|
||||||
void job_notify_change(t_job *job, int status);
|
void job_notify_change(int id, int status);
|
||||||
|
|
||||||
int job_wait(t_job *job);
|
int job_wait(t_job *job);
|
||||||
void job_update_status(void);
|
void job_update_status(void);
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,9 @@ int exec_command(t_btree **ast)
|
||||||
if (process_setexec(p))
|
if (process_setexec(p))
|
||||||
{
|
{
|
||||||
ft_dprintf(2, "{red}%s: command not found: %s{eoc}\n", SHELL_NAME, p->argv[0]);
|
ft_dprintf(2, "{red}%s: command not found: %s{eoc}\n", SHELL_NAME, p->argv[0]);
|
||||||
|
p->attributes = 0;
|
||||||
|
p->path = NULL;
|
||||||
|
p->argv = NULL;
|
||||||
btree_delone(ast, &ast_free);
|
btree_delone(ast, &ast_free);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
@ -39,7 +42,8 @@ int exec_command(t_btree **ast)
|
||||||
put_job_in_background(job, 0);
|
put_job_in_background(job, 0);
|
||||||
}
|
}
|
||||||
btree_delone(ast, &ast_free);
|
btree_delone(ast, &ast_free);
|
||||||
p->path = NULL;
|
|
||||||
p->attributes = 0;
|
p->attributes = 0;
|
||||||
|
p->path = NULL;
|
||||||
|
p->argv = NULL;
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@
|
||||||
|
|
||||||
int process_setexec(t_process *p)
|
int process_setexec(t_process *p)
|
||||||
{
|
{
|
||||||
|
DG("going to setexec:\nenv at %p\nav[0]=%s", data_singleton()->env, p->argv[0]);
|
||||||
|
DG("going to setexec:\nPATH=%s\nav[0]=%s", ft_getenv(data_singleton()->env, "PATH"), p->argv[0]);
|
||||||
if ((p->execf = is_builtin(p)))
|
if ((p->execf = is_builtin(p)))
|
||||||
{
|
{
|
||||||
DG("process is a builtin");
|
DG("process is a builtin");
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,6 @@ void set_exitstatus(int status)
|
||||||
char *astatus;
|
char *astatus;
|
||||||
|
|
||||||
astatus = ft_itoa(status);
|
astatus = ft_itoa(status);
|
||||||
builtin_setenv("shell", (char*[3]){"?", astatus}, data_singleton()->env);
|
builtin_setenv("setenv", (char*[3]){"?", astatus}, data_singleton()->env);
|
||||||
ft_strdel(&astatus);
|
ft_strdel(&astatus);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,18 +24,15 @@ int builtin_jobs(const char *path, char *const av[], char *const envp[])
|
||||||
(void)path;
|
(void)path;
|
||||||
(void)envp;
|
(void)envp;
|
||||||
(void)av;
|
(void)av;
|
||||||
|
rank = '+';
|
||||||
while (jlist)
|
while (jlist)
|
||||||
{
|
{
|
||||||
DG("jlist->content");
|
DG("jlist->content");
|
||||||
job = jlist->content;
|
job = jlist->content;
|
||||||
rank = ' ';
|
ft_printf("{mag}jobs: [%i] %c ", job->id, rank);
|
||||||
if (job->id == data_singleton()->jobc.rank[0])
|
|
||||||
rank = '+';
|
|
||||||
else if (job->id == data_singleton()->jobc.rank[1])
|
|
||||||
rank = '-';
|
|
||||||
ft_printf("{mag}[%i] %c ", job->id, rank);
|
|
||||||
ft_printf("attributes=%x{eoc}\n", job->attributes);
|
ft_printf("attributes=%x{eoc}\n", job->attributes);
|
||||||
jlist = jlist->next;
|
jlist = jlist->next;
|
||||||
|
rank = (rank == '+') ? '-' : ' ';
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,13 +30,13 @@ int do_job_notification(void)
|
||||||
if (job_is_completed(j))
|
if (job_is_completed(j))
|
||||||
{
|
{
|
||||||
ret = 1;
|
ret = 1;
|
||||||
job_notify_change(j, 0);
|
job_notify_change(j->id, 0);
|
||||||
job_remove(j->id);
|
/* job_remove(j->id); */
|
||||||
}
|
}
|
||||||
else if (job_is_stopped(j) && !(j->attributes & JOB_NOTIFIED))
|
else if (job_is_stopped(j) && !(j->attributes & JOB_NOTIFIED))
|
||||||
{
|
{
|
||||||
ret = 1;
|
ret = 1;
|
||||||
job_notify_change(j, 8);
|
job_notify_change(j->id, 8);
|
||||||
j->attributes &= JOB_NOTIFIED;
|
j->attributes &= JOB_NOTIFIED;
|
||||||
}
|
}
|
||||||
jlist = jlist->next;
|
jlist = jlist->next;
|
||||||
|
|
|
||||||
|
|
@ -21,16 +21,15 @@ int job_addprocess(t_process *p)
|
||||||
job = &data_singleton()->exec.job;
|
job = &data_singleton()->exec.job;
|
||||||
if (p->fdin == STDIN)
|
if (p->fdin == STDIN)
|
||||||
{
|
{
|
||||||
job->id = jobc->current_id;
|
|
||||||
job_update_id();
|
job_update_id();
|
||||||
|
job->id = jobc->current_id;
|
||||||
ft_lstadd(&jobc->first_job, ft_lstnew(job, sizeof(*job)));
|
ft_lstadd(&jobc->first_job, ft_lstnew(job, sizeof(*job)));
|
||||||
jobc->rank[1] = jobc->rank[0];
|
DG("added new job [%i], rank=%i:%i", job->id, jobc->rank[0], jobc->rank[1]);
|
||||||
jobc->rank[0] = job->id;
|
|
||||||
}
|
}
|
||||||
job = jobc->first_job->content;
|
job = jobc->first_job->content;
|
||||||
ft_lstadd(&job->first_process, ft_lstnew(p, sizeof(*p)));
|
ft_lstadd(&job->first_process, ft_lstnew(p, sizeof(*p)));
|
||||||
if (JOB_IS_BG(job->attributes) && p->fdout == STDOUT)
|
if (JOB_IS_BG(job->attributes) && p->fdout == STDOUT)
|
||||||
job_notify_new(job);
|
job_notify_new(job);
|
||||||
DG("adding process to first_job : %i", p->pid);
|
DG("added process to first_job : %i", p->pid);
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,16 +12,24 @@
|
||||||
|
|
||||||
#include "job_control.h"
|
#include "job_control.h"
|
||||||
|
|
||||||
void job_notify_change(t_job *job, int status)
|
void job_notify_change(int id, int status)
|
||||||
{
|
{
|
||||||
char rank;
|
t_job *job;
|
||||||
|
t_jobc *jobc;
|
||||||
|
char rank;
|
||||||
|
|
||||||
rank = ' ';
|
rank = ' ';
|
||||||
if (job->id == data_singleton()->jobc.rank[0])
|
jobc = &data_singleton()->jobc;
|
||||||
|
job = jobc->first_job->content;
|
||||||
|
if (id == job->id)
|
||||||
rank = '+';
|
rank = '+';
|
||||||
else if (job->id == data_singleton()->jobc.rank[1])
|
else if (jobc->first_job->next)
|
||||||
rank = '-';
|
{
|
||||||
ft_printf("{mag}[%i] %c ", job->id, rank);
|
job = jobc->first_job->next->content;
|
||||||
|
if (id == job->id)
|
||||||
|
rank = '-';
|
||||||
|
}
|
||||||
|
ft_printf("{mag}[%i] %c ", id, rank);
|
||||||
if (status == 0)
|
if (status == 0)
|
||||||
ft_printf("{gre}done{mag}");
|
ft_printf("{gre}done{mag}");
|
||||||
else if (status == 8)
|
else if (status == 8)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue