int x = 0; if (fork() == 0) { execv(argv[0], argv); x = 1; // this is only executed if execv() fails exit(1); } else { wait (NULL); } // the value of x here is 0, even if execv() fails, in which case i want this value of x to be 1