Back to index

glibc  2.9
tst-execvp1.c
Go to the documentation of this file.
00001 #include <errno.h>
00002 #include <stdio.h>
00003 #include <stdlib.h>
00004 #include <unistd.h>
00005 
00006 static int
00007 do_test (void)
00008 {
00009   char *cwd = get_current_dir_name ();
00010   if (cwd == NULL)
00011     {
00012       puts ("get_current_dir_name failed");
00013       return 1;
00014     }
00015 
00016   /* Make sure we do not find a binary with the name we are going to
00017      use.  */
00018   setenv ("PATH", cwd, 1);
00019 
00020   char *argv[] = { (char *) "does-not-exist", NULL };
00021   errno = 0;
00022   execvp (argv[0], argv);
00023 
00024   if (errno != ENOENT)
00025     {
00026       printf ("errno = %d (%m), expected ENOENT\n", errno);
00027       return 1;
00028     }
00029 
00030   return 0;
00031 }
00032 
00033 #define TEST_FUNCTION do_test ()
00034 #include "../test-skeleton.c"