general improvements, security & reliability & portability

slightly cleaner.

more secure, IE, it leaks less about the key on a string of null chars when sent.

added some IPC to clean up other process in case of failure.

Changed send(), recv() to read(), write() to make it a more general pipe rather than specifically an internet socket.