Get PID of the process sending data to standard input

Based on <http://stackoverflow.com/a/17171333/96588>.