fin mise a la norme exec (reste un fichier mais il faut que vous y regardiez)
This commit is contained in:
parent
b1eaa947a6
commit
03edcfc777
2 changed files with 22 additions and 18 deletions
|
|
@ -1,22 +1,33 @@
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* lib_path.c :+: :+: :+: */
|
/* ft_findexec.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/03 13:37:49 by jhalford #+# #+# */
|
/* Created: 2016/12/03 13:37:49 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/01/10 13:18:56 by jhalford ### ########.fr */
|
/* Updated: 2017/03/20 16:52:10 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
|
||||||
|
static char *create_path(char *path, char *name, char **spath)
|
||||||
|
{
|
||||||
|
char *execpath;
|
||||||
|
|
||||||
|
if (path[ft_strlen(path)] != '/')
|
||||||
|
execpath = ft_str3join(path, "/", name);
|
||||||
|
else
|
||||||
|
execpath = ft_strjoin(path, name);
|
||||||
|
ft_sstrfree(spath);
|
||||||
|
return (execpath);
|
||||||
|
}
|
||||||
|
|
||||||
char *ft_findexec(char *path, char *file)
|
char *ft_findexec(char *path, char *file)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
char *execpath;
|
|
||||||
char **spath;
|
char **spath;
|
||||||
struct dirent *dirent;
|
struct dirent *dirent;
|
||||||
|
|
||||||
|
|
@ -30,13 +41,8 @@ char *ft_findexec(char *path, char *file)
|
||||||
{
|
{
|
||||||
if (ft_strcmp(dirent->d_name, file))
|
if (ft_strcmp(dirent->d_name, file))
|
||||||
continue ;
|
continue ;
|
||||||
if (spath[i][ft_strlen(spath[i])] != '/')
|
|
||||||
execpath = ft_str3join(spath[i], "/", dirent->d_name);
|
|
||||||
else
|
|
||||||
execpath = ft_strjoin(spath[i], dirent->d_name);
|
|
||||||
ft_sstrfree(spath);
|
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
return (execpath);
|
return (create_path(spath[i], dirent->d_name, spath));
|
||||||
}
|
}
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/05 14:54:45 by jhalford #+# #+# */
|
/* Created: 2017/03/05 14:54:45 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/20 16:02:08 by gwojda ### ########.fr */
|
/* Updated: 2017/03/20 17:07:01 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -59,10 +59,8 @@ int process_set(t_process *p, t_btree *ast)
|
||||||
return (1);
|
return (1);
|
||||||
fds[PIPE_WRITE] = STDOUT;
|
fds[PIPE_WRITE] = STDOUT;
|
||||||
fds[PIPE_READ] = STDIN;
|
fds[PIPE_READ] = STDIN;
|
||||||
if (op == TK_PIPE)
|
(op == TK_PIPE) ? pipe(fds) : (0);
|
||||||
pipe(fds);
|
exec->job.attrs |= (op == TK_AMP ? JOB_BG : 0);
|
||||||
else if (op == TK_AMP)
|
|
||||||
exec->job.attrs |= JOB_BG;
|
|
||||||
p->fdin = exec->fdin;
|
p->fdin = exec->fdin;
|
||||||
p->to_close = fds[PIPE_READ];
|
p->to_close = fds[PIPE_READ];
|
||||||
p->fdout = fds[PIPE_WRITE];
|
p->fdout = fds[PIPE_WRITE];
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue