#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>

int main()
{
 int FH1;
 char puffer[10];

 FH1 = open("./auf2.c",O_RDONLY);
 if(FH1 == -1) { /*Fehler*/ exit(0); }

 /*Ist das close-on-exec Flag bereits gelöscht?*/
 if( (fcntl(FH1, F_GETFD, FD_CLOEXEC) == 0) )
  {
   printf("Das close-on-exec Flag ist bereits gelöscht!!\n");
   system("./xt");  /*Programmaufruf*/
  }
 else if( (fcntl(FH1, F_SETFD, FD_CLOEXEC) > 0 )  )
  {
   printf("close-on-exec Flag wurde gerade gesetzt\n");
   system("./xt"); /*Programmaufruf*/
  }
 else
   printf("Konnte das close-on-exec Flag nicht setzen\n");

 return 0;
}