strace/tests/set_ptracer_any.c
Mike Frysinger 6673ac74dc set_ptracer_any: add a little documentation
This way I don't have to keep reading up on these options and wondering
why the code isn't aborting when the call fails.

* tests/set_ptracer_any.c (main): Note prctl failures are ok.
2014-08-11 17:19:17 +00:00

27 lines
594 B
C

#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
/* Turn off restrictions on tracing if applicable. If the options
* aren't available on this system, that's OK too. */
(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;
}