#include <fcntl.h> #include <iostream> #include <unistd.h> using namespace std; int main() { int flags = fcntl(STDOUT_FILENO, F_GETFD); flags |= FD_CLOEXEC; fcntl(STDOUT_FILENO, F_SETFD, flags); if ( fork() == 0 ) { execlp("ls", "ls", (char*)NULL); } cout << "input flags = "; cin >> flags; cout << flags << endl; return 0; }