Java Process without console or terminal

N

nico_zin

I have written a Java class that performs a
Runtime.getRuntime().exec(cmd). The contents of 'cmd' in this case is
the 'gpg' utility that depends quite a bit on stdin/stdout. I have
built a simple command-line interface to this class for testing
purposes. When testing, the utility works perfectly. However, when
the class is packaged up and attempted to be used from a Windows
Service for example, it fails.

Initially, my 'cmd' contained "gpg --passphrase-fd 0 ..." and failed
(error=2) with regards to the --passphrase-fd 0 reference. I then
updated the 'cmd' reference to be "cmd /c gpg ..." and failed elsewhere
throwing an IOException.

Hunting around, the Java.io.Process class definition documents:

"...The created subprocess does not have its own terminal or console.
All its standard io (i.e. stdin, stdout, stderr) operations will be
redirected to the parent process through three streams
(Process.getOutputStream(), Process.getInputStream(),
Process.getErrorStream()). The parent process uses these streams to
feed input to and get output from the subprocess."

I take it when running from a Windows service implies the parent
process doesn't have standard I/O.

I'm not sure if a simple solution is possible. Any help would be
appreciated.

thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,740
Latest member
AdolphBig6

Latest Threads

Top