yes | head fixed

This commit is contained in:
Jack Halford 2017-03-11 18:33:09 +01:00
parent bc97d45f44
commit 230ff16f79
18 changed files with 44 additions and 34 deletions

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/13 17:11:48 by jhalford #+# #+# */
/* Updated: 2017/03/10 20:14:52 by ariard ### ########.fr */
/* Updated: 2017/03/11 16:40:08 by jhalford ### ########.fr */
/* Updated: 2017/03/07 18:35:11 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

@ -1 +1 @@
Subproject commit b209bb1fb718a68256253d5ab5ff69a46a90d5d6
Subproject commit 934ff3af934eaecf04575a0a7e7e1b76628ae53b

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 15:47:30 by wescande #+# #+# */
/* Updated: 2017/03/11 16:00:12 by jhalford ### ########.fr */
/* Updated: 2017/03/11 18:32:51 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 15:48:24 by jhalford #+# #+# */
/* Updated: 2017/03/09 15:12:48 by jhalford ### ########.fr */
/* Updated: 2017/03/11 18:16:25 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 14:53:31 by jhalford #+# #+# */
/* Updated: 2017/03/11 16:00:38 by jhalford ### ########.fr */
/* Updated: 2017/03/11 18:16:40 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -22,6 +22,11 @@ int launch_file(t_process *p)
/* data_singleton()->opts &= ~SH_INTERACTIVE; */
/* data_singleton()->opts &= ~SH_OPTS_JOBC; */
DG("fork! [%s]", p->data.cmd.av[0]);
process_setgroup(p, 0);
process_setsig();
if (process_redirect(p))
exit (1);
exec_reset();
if (!p->data.cmd.path)
{
ft_dprintf(2, "{red}%s: command not found: %s{eoc}\n", SHELL_NAME, p->data.cmd.av[0]);
@ -42,11 +47,6 @@ int launch_file(t_process *p)
ft_dprintf(2, "{red}%s: permission denied: %s{eoc}\n", SHELL_NAME, p->data.cmd.av[0]);
exit(126);
}
process_setgroup(p, 0);
process_setsig();
if (process_redirect(p))
exit (1);
exec_reset();
(*p->data.cmd.execf)(p->data.cmd.path, p->data.cmd.av, data_singleton()->env);
ft_dprintf(2, "{red}%s: internal execve error on %s{eoc}\n", SHELL_NAME, p->data.cmd.av[0]);
exit(42);

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/13 14:20:45 by jhalford #+# #+# */
/* Updated: 2017/03/11 15:49:36 by jhalford ### ########.fr */
/* Updated: 2017/03/11 17:59:03 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -44,7 +44,8 @@ int launch_process(t_process *p)
}
p->pid = pid;
process_setgroup(p, pid);
/* process_resetfds(p); */
if (p->fdin != STDIN)
close(p->fdin);
if (p->fdout != STDOUT)
close(p->fdout);
return (0);

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/08 00:11:44 by wescande #+# #+# */
/* Updated: 2017/03/11 15:38:56 by jhalford ### ########.fr */
/* Updated: 2017/03/11 18:09:35 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,8 +14,12 @@
static int do_subshell(t_process *p)
{
int ret;
ft_exec(&p->data.subshell.content);
return (ft_atoi(ft_getenv(data_singleton()->env, "?")));
ret = ft_atoi(ft_getenv(data_singleton()->env, "?"));
DG("CHECK, ret=[%i]", ret);
return (ret);
}
int launch_subshell(t_process *p)

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 17:20:53 by wescande #+# #+# */
/* Updated: 2017/03/10 17:09:14 by jhalford ### ########.fr */
/* Updated: 2017/03/11 17:45:18 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/12 12:41:11 by jhalford #+# #+# */
/* Updated: 2017/03/10 17:09:04 by jhalford ### ########.fr */
/* Updated: 2017/03/11 18:16:23 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -17,7 +17,17 @@ int mark_process_status(pid_t pid, int status)
t_list *plist;
t_process *p;
DG("MPS pid=%i,s=%i", pid, status);
if (WIFEXITED(status))
DG("MPS pid=[%i] s=[%i] ec=[%i] (exited)", pid, status,
WEXITSTATUS(status));
else if (WIFSIGNALED(status))
DG("MPS pid=[%i] s=[%i] sig=[%i] (signaled)", pid, status,
WTERMSIG(status));
else if (WIFSTOPPED(status))
DG("MPS pid=[%i] s=[%i] (stopped)", pid, status);
else
DG("MPS pid=[%i] s=[%i] (unknown)", pid, status);
if ((plist = job_getprocess(pid)))
{
p = plist->content;

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/29 16:04:18 by jhalford #+# #+# */
/* Updated: 2017/03/11 15:42:46 by jhalford ### ########.fr */
/* Updated: 2017/03/11 16:40:13 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -33,8 +33,9 @@ int process_redirect(t_process *p)
while (redirs)
{
redir = redirs->content;
/* DG("redir type :%s", read_state(redir->type)); */
/* DG("redir word : %s", redir->word); */
DG("redir.type [%i]", redir->type);
DG("redir.word [%s]", redir->word);
DG("redir.n [%i]", redir->n);
if (redir->n > 9)
return (bad_fd(redir->n));
i = 0;

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/09 14:51:23 by jhalford #+# #+# */
/* Updated: 2017/03/10 14:35:00 by jhalford ### ########.fr */
/* Updated: 2017/03/11 17:58:14 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/13 17:48:10 by jhalford #+# #+# */
/* Updated: 2017/03/11 16:05:08 by jhalford ### ########.fr */
/* Updated: 2017/03/11 16:07:43 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -20,11 +20,7 @@ int process_setgroup(t_process *p, pid_t pid)
(void)p;
data = data_singleton();
/* if (!SH_HAS_JOBC(data->opts)) */
/* return (0); */
j = &data->exec.job;
/* if (!j->pgid) */
/* j->pgid = getpid(); */
DG("setpgid(%i, %i)", pid, j->pgid);
if (setpgid(pid, j->pgid) == -1)
ft_dprintf(2, "{red}%s: internal setpgid() error{eoc}\n", SHELL_NAME);

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/06 22:12:31 by jhalford #+# #+# */
/* Updated: 2017/03/10 14:31:24 by jhalford ### ########.fr */
/* Updated: 2017/03/11 17:32:20 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/28 14:25:17 by jhalford #+# #+# */
/* Updated: 2017/02/27 23:20:22 by ariard ### ########.fr */
/* Updated: 2017/03/11 18:14:33 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/05 14:54:45 by jhalford #+# #+# */
/* Updated: 2017/03/11 13:26:33 by jhalford ### ########.fr */
/* Updated: 2017/03/11 17:49:28 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/13 13:54:51 by jhalford #+# #+# */
/* Updated: 2017/03/11 16:05:22 by jhalford ### ########.fr */
/* Updated: 2017/03/11 18:22:29 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -32,8 +32,6 @@ int job_addprocess(t_process *p)
ft_lsteadd(&job->first_process, ft_lstnew(p, sizeof(*p)));
/* DG("[BG:%i]", JOB_IS_BG(job->attrs)); */
if (JOB_IS_BG(job->attrs) && IS_PIPEEND(*p))
{
job_notify_new(job);
}
return (0);
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/13 14:58:36 by jhalford #+# #+# */
/* Updated: 2017/03/11 15:39:43 by jhalford ### ########.fr */
/* Updated: 2017/03/11 18:22:21 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/13 13:51:33 by gwojda #+# #+# */
/* Updated: 2017/03/08 23:47:11 by ariard ### ########.fr */
/* Updated: 2017/03/11 16:14:18 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */