parent
2229354793
commit
dd6817ff61
13 changed files with 47 additions and 40 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/27 20:29:56 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/09 15:14:34 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/10 12:11:21 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/07 15:47:30 by wescande #+# #+# */
|
||||
/* Updated: 2017/03/09 15:21:14 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/10 11:58:54 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/08 14:31:42 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/09 15:22:51 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/10 12:55:57 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -17,9 +17,18 @@ int exec_reset(void)
|
|||
t_exec *exec;
|
||||
|
||||
exec = &data_singleton()->exec;
|
||||
exec->fd_save[0] = fcntl(STDIN, F_DUPFD_CLOEXEC);
|
||||
exec->fd_save[1] = fcntl(STDOUT, F_DUPFD_CLOEXEC);
|
||||
exec->fd_save[2] = fcntl(STDERR, F_DUPFD_CLOEXEC);
|
||||
/* exec->fd_save[0] = 1;//fcntl(STDIN, F_DUPFD_CLOEXEC); */
|
||||
/* exec->fd_save[1] = 1;//fcntl(STDOUT, F_DUPFD_CLOEXEC); */
|
||||
/* exec->fd_save[2] = 1;//fcntl(STDERR, F_DUPFD_CLOEXEC); */
|
||||
DG("check 0");
|
||||
if ((exec->fd_save[0] = fcntl(STDIN, F_DUPFD_CLOEXEC, 10)) == -1)
|
||||
ft_dprintf(2, "{red}%s: internal fcntl error errno=%i %s{eoc}\n", SHELL_NAME, errno);
|
||||
DG("check 1");
|
||||
if ((exec->fd_save[1] = fcntl(STDOUT, F_DUPFD_CLOEXEC, 10)) == -1)
|
||||
ft_dprintf(2, "{red}%s: internal fcntl error errno=%i %s{eoc}\n", SHELL_NAME, errno);
|
||||
if ((exec->fd_save[2] = fcntl(STDERR, F_DUPFD_CLOEXEC, 10)) == -1)
|
||||
ft_dprintf(2, "{red}%s: internal fcntl error errno=%i %s{eoc}\n", SHELL_NAME, errno);
|
||||
DG("saved [%i:%i:%i]", exec->fd_save[0], exec->fd_save[1], exec->fd_save[2]);
|
||||
exec->op_stack = NULL;
|
||||
exec->fdin = STDIN;
|
||||
exec->attrs = 0;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/07 14:53:31 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/09 15:10:15 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/10 12:12:59 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/13 14:20:45 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/09 15:15:33 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/10 11:58:53 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/08 00:11:44 by wescande #+# #+# */
|
||||
/* Updated: 2017/03/08 15:08:04 by wescande ### ########.fr */
|
||||
/* Updated: 2017/03/10 11:51:55 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/12 12:41:11 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/08 18:49:49 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/10 12:51:05 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -18,30 +18,26 @@ int mark_process_status(pid_t pid, int status)
|
|||
t_process *p;
|
||||
|
||||
DG("MPS pid=%i,s=%i", pid, status);
|
||||
if (pid > 1)
|
||||
if ((plist = job_getprocess(pid)))
|
||||
{
|
||||
if ((plist = job_getprocess(pid)))
|
||||
p = plist->content;
|
||||
p->status = status;
|
||||
DG("marking pid=[%i], name=[%s]", p->pid, p->data.cmd.av[0]);
|
||||
if (WIFSTOPPED(status))
|
||||
{
|
||||
p = plist->content;
|
||||
p->status = status;
|
||||
DG("marking pid=[%i], name=[%s]", p->pid, p->data.cmd.av[0]);
|
||||
if (WIFSTOPPED(status))
|
||||
{
|
||||
p->attrs &= ~PROCESS_STATE_MASK;
|
||||
p->attrs |= PROCESS_SUSPENDED;
|
||||
}
|
||||
else
|
||||
{
|
||||
p->attrs &= ~PROCESS_STATE_MASK;
|
||||
p->attrs |= PROCESS_COMPLETED;
|
||||
if (WIFSIGNALED(status))
|
||||
ft_printf("{mag}%d: Terminated by signal %d.\n{eoc}",
|
||||
(int)pid, WTERMSIG(status));
|
||||
}
|
||||
return (0);
|
||||
p->attrs &= ~PROCESS_STATE_MASK;
|
||||
p->attrs |= PROCESS_SUSPENDED;
|
||||
}
|
||||
else
|
||||
{
|
||||
p->attrs &= ~PROCESS_STATE_MASK;
|
||||
p->attrs |= PROCESS_COMPLETED;
|
||||
if (WIFSIGNALED(status))
|
||||
ft_printf("{mag}%d: Terminated by signal %d.\n{eoc}",
|
||||
(int)pid, WTERMSIG(status));
|
||||
}
|
||||
ft_dprintf(2, "{red}No child process %d.\n", pid);
|
||||
return (0);
|
||||
}
|
||||
return (-1);
|
||||
ft_dprintf(2, "{red}No child process %d.\n", pid);
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/09 14:51:23 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/09 15:20:41 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/10 12:51:38 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -19,6 +19,7 @@ void process_resetfds(t_process *p)
|
|||
(void)p;
|
||||
exec = &data_singleton()->exec;
|
||||
dup2(exec->fd_save[0], STDIN);
|
||||
close(STDOUT);
|
||||
dup2(exec->fd_save[1], STDOUT);
|
||||
dup2(exec->fd_save[2], STDERR);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/15 13:01:19 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/08 20:35:18 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/10 12:40:35 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/15 12:56:11 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/08 20:35:12 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/10 12:41:11 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -22,5 +22,5 @@ void job_update_status(void)
|
|||
pid = waitpid(WAIT_ANY, &status, WUNTRACED | WNOHANG);
|
||||
DG("pid=[%d]", pid);
|
||||
}
|
||||
while (!mark_process_status(pid, status));
|
||||
while (pid > 1 && !mark_process_status(pid, status));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/09 15:23:31 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/10 12:12:26 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/09 19:46:24 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/10 12:12:24 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -109,14 +109,14 @@ int main(int ac, char **av)
|
|||
int fd;
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
DG("{inv}{bol}{gre}start of shell{eoc}");
|
||||
shell_init(ac, av);
|
||||
if ((fd = get_input_fd()) < 0)
|
||||
{
|
||||
ft_printf("{red}%s: %s: No such file or directory\n{eoc}", SHELL_NAME, shell_get_avdata());
|
||||
return (1);
|
||||
}
|
||||
DG("{inv}{bol}{gre}start of shell{eoc} JOBC is %s, fd=[%i]",
|
||||
SH_HAS_JOBC(data_singleton()->opts)?"ON":"OFF", fd);
|
||||
DG("JOBC is %s, fd=[%i]", SH_HAS_JOBC(data_singleton()->opts)?"ON":"OFF", fd);
|
||||
while (handle_instruction(fd) == 0)
|
||||
{
|
||||
DG();
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/12 17:23:59 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/08 23:42:47 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/10 12:12:30 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -17,6 +17,7 @@ void shell_init(int ac, char **av)
|
|||
int *shell_pgid;
|
||||
t_data *data;
|
||||
|
||||
DG("check");
|
||||
data_init();
|
||||
data = data_singleton();
|
||||
data->argc = ac;
|
||||
|
|
|
|||
Loading…
Reference in a new issue