Blame posix/tst-execvp4.c
|
Packit |
6c4009 |
#include <errno.h>
|
|
Packit |
6c4009 |
#include <stdio.h>
|
|
Packit |
6c4009 |
#include <stdlib.h>
|
|
Packit |
6c4009 |
#include <string.h>
|
|
Packit |
6c4009 |
#include <unistd.h>
|
|
Packit |
6c4009 |
#include <sys/stat.h>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#ifndef EXECVP
|
|
Packit |
6c4009 |
# define EXECVP(file, argv) execvp (file, argv)
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
static int
|
|
Packit |
6c4009 |
do_test (void)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
char buf[40] = "/usr/bin/does-not-exist";
|
|
Packit |
6c4009 |
size_t stemlen = strlen (buf);
|
|
Packit |
6c4009 |
struct stat64 st;
|
|
Packit |
6c4009 |
int cnt = 0;
|
|
Packit |
6c4009 |
while (stat64 (buf, &st) != -1 || errno != ENOENT
|
|
Packit |
6c4009 |
|| stat64 (buf + 4, &st) != -1 || errno != ENOENT)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
if (cnt++ == 100)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
puts ("cannot find a unique file name");
|
|
Packit |
6c4009 |
return 0;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
strcpy (buf + stemlen, ".XXXXXX");
|
|
Packit |
6c4009 |
mktemp (buf);
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
unsetenv ("PATH");
|
|
Packit |
6c4009 |
char *argv[] = { buf + 9, NULL };
|
|
Packit |
6c4009 |
EXECVP (argv[0], argv);
|
|
Packit |
6c4009 |
return 0;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#define TEST_FUNCTION do_test ()
|
|
Packit |
6c4009 |
#include "../test-skeleton.c"
|