Commit ae09acea authored by pêle-mêle's avatar pêle-mêle
Browse files

errno management

parent 8271eb44
......@@ -25,8 +25,6 @@ masaki:
ajouter des errno = 0 ?
builtins: set stat_loc?
mkdir ok; cd ok; rmdir ../ok; pwd
......
......@@ -9,8 +9,8 @@
void child_setup(const int *fd, int fd_in)
{
signal(SIGINT, SIG_DFL);
signal(SIGQUIT, SIG_DFL);
signal(SIGINT, SIG_DFL); // error if SIG_ERR? (check errno)
signal(SIGQUIT, SIG_DFL); // error if SIG_ERR? (check errno)
close(fd[0]);// error
if (fd_in != STDIN_FILENO)
{
......
......@@ -19,8 +19,7 @@ int ft_cd(char **args, t_xe *xe)
path = ft_strdup(args[1]);
if (path == NULL)
return (SUCCESS); // err
errno = 0;
oldpwd = getcwd(NULL, 0);
oldpwd = getcwd(NULL, 0); // error
if (chdir(path) == ERROR)
{
perror("cd");
......
......@@ -20,6 +20,7 @@ static int search_path(DIR *dirp, char *name)
{
struct dirent *buf;
errno = 0; // to distinguish the NULL ret value: end of stream, or error
buf = readdir(dirp);
while (buf != NULL)
{
......@@ -27,6 +28,8 @@ static int search_path(DIR *dirp, char *name)
return (SUCCESS);
buf = readdir(dirp);
}
if (errno != 0)
;//error
return (FAILURE);
}
......@@ -100,8 +103,8 @@ static int launch_ext(char **args, t_xe *xe)
}
else
{
signal(SIGINT, SIG_IGN);
signal(SIGQUIT, SIG_IGN);
signal(SIGINT, SIG_IGN); // error if SIG_ERR? (check errno)
signal(SIGQUIT, SIG_IGN); // error if SIG_ERR? (check errno)
waitpid(pid, &xe->stat_loc, 0); // return value? error?
free_str_array(path);
if (WIFSIGNALED(xe->stat_loc)) // check this return value
......@@ -110,7 +113,7 @@ static int launch_ext(char **args, t_xe *xe)
}
else if (xe->stat_loc > 256)
xe->stat_loc = xe->stat_loc / 256;
signal_handler();
signal_handler(); // err
}
return (ret);
}
......
......@@ -28,6 +28,6 @@ void sig_kill(int signum)
void signal_handler(void)
{
signal(SIGINT, sig_int);
signal(SIGQUIT, sig_kill);
signal(SIGINT, sig_int); // error if SIG_ERR? (check errno)
signal(SIGQUIT, sig_kill); // error if SIG_ERR? (check errno)
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment