a) the program has to actively run its check while being ptraced to notice. If you attach to the program (which pauses it), inject your code, run your code, and then detach, the program's own code will not notice it's being ptraced, no?
b) if you want to run the program's own code while being ptraced, can't you just stop on the ptrace syscall and lie about its result? I think `strace -e inject=ptrace:errno=0` will avoid the program in that wiki page from realizing it's being traced. (You can use seccomp-bpf for this if you don't want to take the performance overhead of stopping on every syscall.)