nelhage / reptyr

Reparent a running program to a new terminal
MIT License
5.77k stars 216 forks source link

fix compilation on musl (or libc without __ptrace_request enum) #80

Closed sairon closed 7 years ago

sairon commented 7 years ago

The compilation on musl fails because __ptracerequest enum does not exist. All the PTRACE* constants from ptrace.h are simple defined integers. int is used instead of enum when PTRACE_TRACEME is defined in preprocessing.

nelhage commented 7 years ago

Is there a good or fundamental reason that PTRACE_TRACEME will be defined iff __ptrace_request exists, or does that just "happen to work" today?

sairon commented 7 years ago

I can't guarantee that PTRACE_TRACEME will cease to exist once the __ptrace_request gets its way to musl but it is true at least in the proposed patch in musl's mailing list: http://www.openwall.com/lists/musl/2015/09/17/1

It is also undefined in uClibc and glibc, so this heuristics seems right. Or do you have another suggestion how to decide which signature should be used?

nelhage commented 7 years ago

Yeah, OK, this makes sense to me – if it's defined, it's probably not an enumeration, and vice versa.

Thanks for the patch!