> Since PTRACE_O_TRACECLONE/*FORK were introduced to kernel
> at the same time, so this test seems enough for these 3 options.

I agree.

> +#ifdef LINUX
> +/* Test whether kernel support PTRACE_O_TRACECLONE et al options.
> + * First fork a new child, call ptrace with PTRACE_SETOPTIONS on it,
> + * and then see which options are supported on this kernel.
> + */
> +int test_ptrace_setoptions()

There is no reason this can't be static, so make it static.
Also, we're using prototypes now, so make its argument list (void).

> +     unsigned int test_options = PTRACE_O_TRACEFORK;

IMHO using an unchanging variable for this is less clear, not more.
Just use the constant in the actual call below.

> +             kill(getpid(), SIGSTOP);

Might as well use raise, though it's the same.

> +             if ((pid = fork()) < 0) {
> +                     exit(1);
> +             }
> +             exit(0);

Not that it really matters here where the parent hasn't used stdio output
calls beforehand, but a fork child should use _exit rather than exit.

> +     }
> +     else {
> +             int status, tracee_pid, wait_errno;
> +             int no_child = 0;
> +             while(1) {

Put a space after the while keyword.

> +                     if (tracee_pid != pid)
> +                             ptrace(PTRACE_CONT, tracee_pid, 0, 0);

You check every other error, so might as well check the ptrace result too.

> +                             ptrace(PTRACE_SYSCALL, pid, 0, 0);

Likewise here.

> +#ifdef LINUX
> +     if (test_ptrace_setoptions() < 0) {
> +             fprintf(stderr, "Test for options supported by 
> PTRACE_SETOPTIONS\
> +                     failed, give up using this feature\n");
> +             ptrace_setoptions = 0;

There is no reason to do the test at all unless followfork is set (-f/-F).


Thanks,
Roland

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
Strace-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to