summaryrefslogtreecommitdiff
path: root/tests/set_ptracer_any.c
blob: 7254a07fb7879acb15e642de7ebd5c91347fc0f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include <unistd.h>
#ifdef HAVE_PRCTL
# include <sys/prctl.h>
#endif

int main(int argc, char **argv)
{
	if (argc < 2)
		return 99;
#if defined HAVE_PRCTL && defined PR_SET_PTRACER && defined PR_SET_PTRACER_ANY
	(void) prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY);
#endif
	if (write(1, "\n", 1) != 1) {
		perror("write");
		return 99;
	}
	(void) execvp(argv[1], argv + 1);
	perror(argv[1]);
	return 99;
}