TP3
This commit is contained in:
parent
d7a70d5d8c
commit
458013fe74
31
SCR3.1/TP3/diff.c
Normal file
31
SCR3.1/TP3/diff.c
Normal file
@ -0,0 +1,31 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <wait.h>
|
||||
#include <fcntl.h>
|
||||
de
|
||||
|
||||
int main(int argc, char **argv){
|
||||
if (argc != 3){
|
||||
printf("Usage : %s <FILE1> <FILE2> | This program compares two files and is able to detect if they are different or same\n", argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
pid_t p;
|
||||
int fd1, fd2;
|
||||
char buf[BUF_SIZE];
|
||||
fd1 = open(argv[1], O_RDONLY);
|
||||
fd2 = open(argv[2], O_RDONLY);
|
||||
if (fd1 == -1 || fd2 == -1){
|
||||
perror("Error while opening files");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
p = fork();
|
||||
switch(p){
|
||||
case -1:
|
||||
perror("Error while creating a new process");
|
||||
return EXIT_FAILURE;
|
||||
case 0:
|
||||
while(read
|
||||
|
Loading…
Reference in New Issue
Block a user