C#, GnuPG and /dev/tty

Robert J. Hansen rjh at sixdemonbag.org
Wed Dec 29 19:25:46 CET 2004


While hacking together a C# script to automate some key management
tasks, I discovered some behavior which is radically different on
Windows as opposed to UNIX.  It appears to be a GnuPG difference, and
not a CLR problem.  Here's the essentials of it:

A new ProcessStateInfo object is created which contains the necessary
information about the GnuPG process--path, executable name, things like
that, along with RedirectStandardOutput set to true.  A new Process is
created, passing our ProcessStateInfo object into its constructor, and a
new StreamReader is hooked up to our process's StandardOutput accessor.

So far, everything works great.  I'm able to grab GnuPG's output, parse
it, and do cool things.

Where things break is when I set RedirectStandardInput to be true and
hook a StreamWriter up to it.  Then I get different behavior depending
on which OS is in use.  On UNIX I get an error message about how it
can't open /dev/tty, and GnuPG aborts.  On Windows, everything works fine.

I've tried passing --no-tty, but that causes it to fail on both platforms.

Can someone help me figure out precisely what I'm doing wrong here?  It
must be something simple.



More information about the Gnupg-devel mailing list