TP5
This commit is contained in:
parent
ff442426c1
commit
d6da59320c
20
SCR3.1/TP5/ex1.1.c
Normal file
20
SCR3.1/TP5/ex1.1.c
Normal 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
15
SCR3.1/TP5/ex2.c
Normal 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);
|
||||
|
Loading…
Reference in New Issue
Block a user