parent
2229354793
commit
dd6817ff61
13 changed files with 47 additions and 40 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/27 20:29:56 by jhalford #+# #+# */
|
/* 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> +#+ +:+ +#+ */
|
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/07 15:47:30 by wescande #+# #+# */
|
/* 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> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/08 14:31:42 by jhalford #+# #+# */
|
/* 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;
|
t_exec *exec;
|
||||||
|
|
||||||
exec = &data_singleton()->exec;
|
exec = &data_singleton()->exec;
|
||||||
exec->fd_save[0] = fcntl(STDIN, F_DUPFD_CLOEXEC);
|
/* exec->fd_save[0] = 1;//fcntl(STDIN, F_DUPFD_CLOEXEC); */
|
||||||
exec->fd_save[1] = fcntl(STDOUT, F_DUPFD_CLOEXEC);
|
/* exec->fd_save[1] = 1;//fcntl(STDOUT, F_DUPFD_CLOEXEC); */
|
||||||
exec->fd_save[2] = fcntl(STDERR, 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->op_stack = NULL;
|
||||||
exec->fdin = STDIN;
|
exec->fdin = STDIN;
|
||||||
exec->attrs = 0;
|
exec->attrs = 0;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/07 14:53:31 by jhalford #+# #+# */
|
/* 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> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/13 14:20:45 by jhalford #+# #+# */
|
/* 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> +#+ +:+ +#+ */
|
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/08 00:11:44 by wescande #+# #+# */
|
/* 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> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/12 12:41:11 by jhalford #+# #+# */
|
/* 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,8 +18,6 @@ int mark_process_status(pid_t pid, int status)
|
||||||
t_process *p;
|
t_process *p;
|
||||||
|
|
||||||
DG("MPS pid=%i,s=%i", pid, status);
|
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 = plist->content;
|
||||||
|
|
@ -43,5 +41,3 @@ int mark_process_status(pid_t pid, int status)
|
||||||
ft_dprintf(2, "{red}No child process %d.\n", pid);
|
ft_dprintf(2, "{red}No child process %d.\n", pid);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/09 14:51:23 by jhalford #+# #+# */
|
/* 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;
|
(void)p;
|
||||||
exec = &data_singleton()->exec;
|
exec = &data_singleton()->exec;
|
||||||
dup2(exec->fd_save[0], STDIN);
|
dup2(exec->fd_save[0], STDIN);
|
||||||
|
close(STDOUT);
|
||||||
dup2(exec->fd_save[1], STDOUT);
|
dup2(exec->fd_save[1], STDOUT);
|
||||||
dup2(exec->fd_save[2], STDERR);
|
dup2(exec->fd_save[2], STDERR);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/15 13:01:19 by jhalford #+# #+# */
|
/* 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> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/15 12:56:11 by jhalford #+# #+# */
|
/* 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);
|
pid = waitpid(WAIT_ANY, &status, WUNTRACED | WNOHANG);
|
||||||
DG("pid=[%d]", pid);
|
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> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */
|
/* 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> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */
|
/* 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;
|
int fd;
|
||||||
|
|
||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, "");
|
||||||
|
DG("{inv}{bol}{gre}start of shell{eoc}");
|
||||||
shell_init(ac, av);
|
shell_init(ac, av);
|
||||||
if ((fd = get_input_fd()) < 0)
|
if ((fd = get_input_fd()) < 0)
|
||||||
{
|
{
|
||||||
ft_printf("{red}%s: %s: No such file or directory\n{eoc}", SHELL_NAME, shell_get_avdata());
|
ft_printf("{red}%s: %s: No such file or directory\n{eoc}", SHELL_NAME, shell_get_avdata());
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
DG("{inv}{bol}{gre}start of shell{eoc} JOBC is %s, fd=[%i]",
|
DG("JOBC is %s, fd=[%i]", SH_HAS_JOBC(data_singleton()->opts)?"ON":"OFF", fd);
|
||||||
SH_HAS_JOBC(data_singleton()->opts)?"ON":"OFF", fd);
|
|
||||||
while (handle_instruction(fd) == 0)
|
while (handle_instruction(fd) == 0)
|
||||||
{
|
{
|
||||||
DG();
|
DG();
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/12 17:23:59 by jhalford #+# #+# */
|
/* 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;
|
int *shell_pgid;
|
||||||
t_data *data;
|
t_data *data;
|
||||||
|
|
||||||
|
DG("check");
|
||||||
data_init();
|
data_init();
|
||||||
data = data_singleton();
|
data = data_singleton();
|
||||||
data->argc = ac;
|
data->argc = ac;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue