better spawn, minus race condition on exit
some of these changes are duplicated from gpg-wrapper, but we port them here anyways