/** * * @File : exo_05.cxx * * @Authors : A.B. Dragut * * @Date : 2011 * * @Synopsis : Heritage des descripteurs de fichiers ouverts * en execution, drapeau O_CLOSEONEXEC * Linux kernel >2.6.23 et glibc >2.7, open a le drapeau * O_CLOEXEC * Linux kernel >2.6.27 et glibc >2.9, pipe2, dup3 * ont aussi des O_CLOEXEC * #define _GNU_SOURCE * #include * pipe2(pipefds, O_CLOEXEC);dup3(oldfd, newfd, O_CLOEXEC); * **/ #include #include #include // execl() #include // O_RDONLY #include "CExc.h" #include "nsSysteme.h" // Fork(), Signal() using namespace std; using namespace nsSysteme; // Fork(), Signal() using namespace nsFctShell; //TestFdOuverts(); int main(int argc, char * argv []) { try { if (1 != argc) throw CExc("main()",string ("Usage : ") + argv [0]); Open ("exo_05.txt", O_WRONLY|O_CREAT,0700); Open ("exo_05.txt", O_RDONLY); //int fd3= Open ("exo_05.txt", O_RDWR|O_CLOEXEC); //////////////////////////////////////////////////////////////////////////////////////// //alternative avec fcntl() // if ((flags = fcntl(fd3, F_GETFD)) != -1) // fcntl(fd, F_SETFD, flags | FD_CLOEXEC); // TestFdOuverts(); ::execl ("exo_05_x.run", "exo_05_x.run", "lance ", "par ", argv [0], static_cast(0)); throw CExc("execl()",""); return 0; } catch (const CExc & Exc) { cerr <