3 Commits

Author SHA1 Message Date
lucas 7f7d22e346 Téléverser les fichiers vers "/" 2026-05-11 16:53:12 +00:00
lucas b74419747b correction code 2026-04-17 17:28:11 +02:00
lucas 53548f9159 suppression du main de pipe.c 2026-04-16 23:21:56 +02:00
6 changed files with 2828 additions and 16 deletions
File diff suppressed because one or more lines are too long
+2 -1
View File
@@ -42,4 +42,5 @@ printf("%d\n", r1);
int r2 = execute_me("wrong", argv);
printf("%d\n", r2);
}*/
}
*/
+2 -2
View File
@@ -44,7 +44,7 @@ void piped(){
char buffer[2048];
read(fd[0], buffer, sizeof(buffer));
printf("My child sends me : %s\n", buffer);
printf("My child sends me : %s", buffer);
close(fd[0]);
wait(NULL);
@@ -53,4 +53,4 @@ void piped(){
}
int main(){ piped();}
//int main(){ piped();}
+1 -1
View File
@@ -14,7 +14,7 @@ int fibo (int n){
}
int wait_child(int x){
if(x < 0) return -1;
if(x < 0) return 1;
int wstatus;
pid_t pid = fork();
+14 -4
View File
@@ -25,18 +25,28 @@ int duper(char **argv, char *output){
int wstatus;
pid_t pid = fork();
if(pid < 0) return 1;
if(pid < 0) {
printf("Something went wrong in duper.\n");
return 1;
}
//Child
else if (pid == 0){
// ouverture en mode write
FILE *file = fopen(output, "w");
if(!file) exit(-1);
if(!file) {
printf("Something went wrong in duper.\n");
exit(-1);
}
int fno = fileno(file);
if(dup2(fno, STDOUT_FILENO) == -1) exit(-1);
if(dup2(fno, STDOUT_FILENO) == -1){
printf("Something went wrong in duper.\n");
exit(-1);
}
fclose(file);
+9 -5
View File
@@ -65,17 +65,21 @@ int exec_cmd(char** args){
int wstatus;
pid_t pid = fork();
if (pid < 0) exit(-1);
if (pid < 0){
free(args);
exit(-1);
}
// Child
else if (pid == 0){
if(strcmp(args[0] , "run") != 0) exit(-1);
//if(strcmp(args[0] , "run") != 0) exit(-1);
if(execvp(args[1], args + 1) != 0) exit(-1);
exit(0);
//on execute la commande et on return son code de fin
exit(execvp(args[1], args + 1));
//if(execvp(args[0], args) == -1) exit(-1);
//if(execvp(args[1], args + 1) != 0) exit(-1);
//exit(0);
}
//Uncle... You're again ! Oh it's not my uncle it's my daddy !