Fix crash on OSX when Mono internally frees a System.Diagnostics.Process.

Changes ported from upstream mono fixes made in 2010:
https://github.com/mono/mono/commit/579a0ca72b996d11a50ddf6ddb4f67e59995072d
https://github.com/mono/mono/commit/3b6f5c33088c53280980218f82168e3cba00a25b

More details on this issue: http://mono.1490590.n4.nabble.com/Process-SIGSEGV-on-Mono-2-8p6-td2713681.html
Local merge.