This commit is contained in:
Arnaud NGWALA NGWALA 2023-10-05 15:01:26 +02:00
parent ff442426c1
commit d6da59320c
2 changed files with 35 additions and 0 deletions

20
SCR3.1/TP5/ex1.1.c Normal file
View File

@ -0,0 +1,20 @@
#define _GNU_SOURCE
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>
int main(int argc, char *argv[])
{
int t[2];
int size;
assert(pipe(t) == 0);
size = fcntl(t[0],F_GETPIPE_SZ);
printf("size = %d\n",size);
return 0;
}

15
SCR3.1/TP5/ex2.c Normal file
View File

@ -0,0 +1,15 @@
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char** argv){
if (args != 2){
printf("Usage : %s <file>", argv[0]);
return EXIT_FAILURE;
}
int p[2], fd;
fd = open(argv[1],
pipe(p);
execl("/usr/bin/ls", "ls", "-i", "-l", "/tmp", NULL);
dup2(p[0],0);