debut mise a la norme exec

This commit is contained in:
gwojda 2017-03-20 16:29:40 +01:00
commit d1250c5142
5 changed files with 8 additions and 14 deletions

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:33:27 by jhalford #+# #+# */
/* Updated: 2017/03/20 16:10:35 by jhalford ### ########.fr */
/* Updated: 2017/03/20 16:13:24 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:57:33 by jhalford #+# #+# */
/* Updated: 2016/11/16 12:23:13 by jhalford ### ########.fr */
/* Updated: 2017/03/20 16:19:07 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/08 00:58:02 by wescande #+# #+# */
/* Updated: 2017/03/20 15:50:07 by gwojda ### ########.fr */
/* Updated: 2017/03/20 16:29:37 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 14:53:31 by jhalford #+# #+# */
/* Updated: 2017/03/20 15:50:17 by gwojda ### ########.fr */
/* Updated: 2017/03/20 16:29:20 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -22,7 +22,7 @@ int plaunch_file(t_process *p)
{
if (!p->data.cmd.path)
error_launch("command not found: ", p->data.cmd.av[0], 127);
else if (!p->data.cmd.stat)
else if (access(p->data.cmd.path, F_OK) == -1)
error_launch(p->data.cmd.av[0], ": no such file or directory", 127);
else if (S_ISDIR(p->data.cmd.stat->st_mode))
error_launch(p->data.cmd.av[0], ": is a directory", 126);

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/20 12:41:54 by jhalford #+# #+# */
/* Updated: 2017/03/20 15:39:40 by jhalford ### ########.fr */
/* Updated: 2017/03/20 16:28:02 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -28,19 +28,13 @@ int pset_cmd(t_process *p, t_btree *ast)
p->type = PROCESS_BUILTIN;
else if ((p->type = PROCESS_FILE))
{
DG();
p->data.cmd.stat = ft_memalloc(sizeof(struct stat));
p->data.cmd.execf = &execve;
p->data.cmd.path = ft_strchr(p->data.cmd.av[0], '/') ?
ft_strdup(p->data.cmd.av[0]) : ft_hash(p->data.cmd.av[0]);
if (stat(p->data.cmd.path, p->data.cmd.stat) == -1)
{
ft_memdel((void**)&p->data.cmd.stat);
ft_dprintf(2, "{red}%s: %s: unexpected stat (2) failure\n",
SHELL_NAME, p->data.cmd.path);
if (p->data.cmd.path && !access(p->data.cmd.path, F_OK)
&& stat(p->data.cmd.path, p->data.cmd.stat) == -1)
return (-1);
}
}
DG();
return (0);
}