double_pipe.c

This commit is contained in:
2026-04-16 23:19:25 +02:00
parent 588d27633b
commit 9a472fdd08
7 changed files with 54 additions and 98 deletions
+6 -4
View File
@@ -60,6 +60,8 @@ char** split(char* line){
int exec_cmd(char** args){
if(!args || !*args) return -1;
int wstatus;
pid_t pid = fork();
@@ -85,7 +87,7 @@ int exec_cmd(char** args){
if(waitpid(pid, &wstatus, 0) == -1) return -1;
if( WIFEXITED(wstatus)){
if(WEXITSTATUS(wstatus) == 255) return 1;
if(WEXITSTATUS(wstatus) == 255) return -1;
else return WEXITSTATUS(wstatus);
}}
return 0;
@@ -135,7 +137,7 @@ int execution_loop(){
//execution du run <commande> via le child
else if (strcmp(args[0], "run") == 0){
//printf("test\n");
last_code = exec_cmd(args);
if(args[1]) last_code = exec_cmd(args);
}
//interrogation du last_code
@@ -158,11 +160,11 @@ int is_terminal()
{
return isatty(STDIN_FILENO) && isatty(STDOUT_FILENO);
}
/*
int main() {
printf("\n Code de fin : %i\n",execution_loop());
}
*/
/*
int main(){