Skip to content

Commit

Permalink
addas
Browse files Browse the repository at this point in the history
  • Loading branch information
juansedev committed Apr 15, 2020
1 parent 1981f9e commit 891db4c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
8 changes: 1 addition & 7 deletions create_process.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,14 @@
int create_process(char *av[], int count_exe)
{
char *full_path = NULL, *full_file = NULL, error_msg[100];
struct stat st;
/*struct stat st;*/

sprintf(error_msg, "%s: %d: %s: not found\n", av[0], count_exe, av[1]);
full_path = _getenv("PATH");
full_file = validate_file(full_path, av[1]);
free(full_path);
if ((execve(full_file, (av + 1), environ)) == -1)
{
if (stat(full_file, &st) == 0)
{
free(full_file);
return (126);
}
free(full_file);
write(2, error_msg, strlen(error_msg));
return (127);
}
Expand Down
Binary file added hsh
Binary file not shown.
9 changes: 6 additions & 3 deletions interactive.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ int interactive(char *av[], int count_exe, char **env)
{
if (_strncmp(line, "env\n", 3) == 0)
print_env(env);
if (read > 1)
else if (read > 1)
{
token = strtok(line, " \t\n\r");
args[0] = av[0];
Expand All @@ -48,10 +48,13 @@ int interactive(char *av[], int count_exe, char **env)
args[i] = token;
token = strtok(NULL, " \t\n\r");
} args[i] = NULL;
if (*args)
status_process = child_process(args, count_exe);
if (args[1])
status_process = child_process(args, count_exe);
if (status_process == 127)
{
free(line);
return (status_process);
}
} count_exe++;
}
}
Expand Down

0 comments on commit 891db4c

Please sign in to comment.