Add 469782 to NEWS
[valgrind.git] / none / tests / nocwd.c
blobd01d6237733c5fddf921122a54f004114951061b
1 #include <limits.h>
2 #include <stdlib.h>
3 #include <stdio.h>
4 #include <string.h>
5 #include <unistd.h>
6 #include <sys/stat.h>
7 #include <sys/types.h>
9 int
10 main (int argc, char **argv)
12 char template[] = "/tmp/wd_test_XXXXXX";
13 char *tmpdir = mkdtemp(template);
14 if (tmpdir == NULL)
16 perror ("Couldn't mkdtemp");
17 exit (-1);
20 if (chdir (tmpdir) != 0)
22 perror ("Couldn't chdir into tmpdir");
23 exit (-1);
26 /* Go deep. */
27 int dirslen = PATH_MAX;
28 while (dirslen > 0)
30 /* We don't do any error checking in case some OS fails. */
31 mkdir ("subdir", S_IRWXU);
32 chdir ("subdir");
33 dirslen -= strlen ("subdir");
36 /* Make one component inaccessible. */
37 chmod(tmpdir, 0);
39 /* Remove the current dir (don't check error, might fail). */
40 rmdir ("../subdir");
42 execlp ("echo", "echo", "Hello", "World", (char *) NULL);
43 perror ("Couldn't execlp");
44 return -1;