From d6da59320c7b7a05891f9738681570eeb396b746 Mon Sep 17 00:00:00 2001 From: ngwalang Date: Thu, 5 Oct 2023 15:01:26 +0200 Subject: [PATCH] TP5 --- SCR3.1/TP5/ex1.1.c | 20 ++++++++++++++++++++ SCR3.1/TP5/ex2.c | 15 +++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 SCR3.1/TP5/ex1.1.c create mode 100644 SCR3.1/TP5/ex2.c diff --git a/SCR3.1/TP5/ex1.1.c b/SCR3.1/TP5/ex1.1.c new file mode 100644 index 0000000..46b76f6 --- /dev/null +++ b/SCR3.1/TP5/ex1.1.c @@ -0,0 +1,20 @@ +#define _GNU_SOURCE +#include +#include +#include +#include +#include + + +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; +} diff --git a/SCR3.1/TP5/ex2.c b/SCR3.1/TP5/ex2.c new file mode 100644 index 0000000..f65d7aa --- /dev/null +++ b/SCR3.1/TP5/ex2.c @@ -0,0 +1,15 @@ +#include +#include +#include + +int main(int argc, char** argv){ + if (args != 2){ + printf("Usage : %s ", 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); +