tests: robustify set_ptracer_any

* tests/set_ptracer_any.c (main) [HAVE_PRCTL]: Provide fallback
definitions for PR_SET_PTRACER and PR_SET_PTRACER_ANY constants,
set all unused prctl arguments to 0.
This commit is contained in:
Дмитрий Левин 2018-01-24 01:56:15 +00:00
parent c7e8fc0e63
commit ceceb4dffb

View File

@ -37,10 +37,16 @@ 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
#ifdef HAVE_PRCTL
/* Turn off restrictions on tracing if applicable. If the command
* aren't available on this system, that's OK too. */
(void) prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY);
# ifndef PR_SET_PTRACER
# define PR_SET_PTRACER 0x59616d61
# endif
# ifndef PR_SET_PTRACER_ANY
# define PR_SET_PTRACER_ANY -1UL
# endif
(void) prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY, 0, 0, 0);
#endif
if (write(1, "\n", 1) != 1) {
perror("write");