Overwriting the process's code with zero (in x86) is most likely NOT going to stop the process from executing, but since that becomes a plain instruction, I think ADD EAX, [EAX], it will just walk all the way to the end of the code segment [unless EAX is pointing at invalid memory]. Obviously, if the registers for the process are set to some invalid memory address [in 64-bit, a value that is non-canonical will be good, in 32-bit, something that is write-protected, such as zero], and/or the memory is filled with something that causes an "invalid opcode", then that would be a different matter.
I really don't see how this can be "better" than using SIGKILL
(aka KILL -9 pid
) - if the process is blocked inside the kernel and somehow not leaving the kernel, it won't help to overwrite the code-space, since the process isn't running that code anyway. If there is a bug in the kernel, it's not really going to matter what you do to the process' userspace memory. Fix the kernel bug!