]> git.ipfire.org Git - thirdparty/glibc.git/blob - posix/tst-execvp4.c
2.5-18.1
[thirdparty/glibc.git] / posix / tst-execvp4.c
1 #include <errno.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <string.h>
5 #include <unistd.h>
6 #include <sys/stat.h>
7
8 static int
9 do_test (void)
10 {
11 char buf[40] = "/usr/bin/does-not-exist";
12 size_t stemlen = strlen (buf);
13 struct stat64 st;
14 int cnt = 0;
15 while (stat64 (buf, &st) != -1 || errno != ENOENT
16 || stat64 (buf + 4, &st) != -1 || errno != ENOENT)
17 {
18 if (cnt++ == 100)
19 {
20 puts ("cannot find a unique file name");
21 return 0;
22 }
23
24 strcpy (buf + stemlen, ".XXXXXX");
25 mktemp (buf);
26 }
27
28 unsetenv ("PATH");
29 char *argv[] = { buf + 9, NULL };
30 execvp (argv[0], argv);
31 return 0;
32 }
33
34 #define TEST_FUNCTION do_test ()
35 #include "../test-skeleton.c"