Make ptrace emulation work when seccomp-filter is enabled.
Fix a couple of portability issues.