tammana
asked on
Process Spawning and I/O redirection
I am trying to do the following but can't seem to find a way to
do it in java. I am looking for suggestions ...
I am looking for a way to spawn a process and redirect the stdout
and stderr to a file. What I did in C/C++ was to create a file
in the parent process and manipulate the stdout and stderr (using
dup on unix and the win32 CreateProcess API on NT) and then spawn
the child. Is there a way to achieve this ?
Note:
The child process is a legacy app (I don't have the source code).
I just want to launch it and make its stdout and stderr go to a
flat file.
Also, after spawning the process, I am looking for a way to verify
if the process is running or terminated. Is there anyway to do this ?
I have the process handle/class that was returned when the process
was spawned. I couldn't find an API call for that either.
I guess if I can do the above, I will look for more :-) facilities
like retrieving environment variables and setting uid's etc. For
now, I'd like to start with these.
Any help appreciated.
Thanks,
-krishna
do it in java. I am looking for suggestions ...
I am looking for a way to spawn a process and redirect the stdout
and stderr to a file. What I did in C/C++ was to create a file
in the parent process and manipulate the stdout and stderr (using
dup on unix and the win32 CreateProcess API on NT) and then spawn
the child. Is there a way to achieve this ?
Note:
The child process is a legacy app (I don't have the source code).
I just want to launch it and make its stdout and stderr go to a
flat file.
Also, after spawning the process, I am looking for a way to verify
if the process is running or terminated. Is there anyway to do this ?
I have the process handle/class that was returned when the process
was spawned. I couldn't find an API call for that either.
I guess if I can do the above, I will look for more :-) facilities
like retrieving environment variables and setting uid's etc. For
now, I'd like to start with these.
Any help appreciated.
Thanks,
-krishna
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I already have the app in native (C) code. If I have to have
platform specific code, there is not much benefit for me.
Anyway, I was looking more for an equivalent of "dup" call
under UNIX which will allow me to dup the file handles 1 & 2
(stdout and stderr) to point to a file before spawning. I was
hoping that java had such a call. NT allows this also in the
Win32 API.
Oh well! Thanks for the answer.
-krishna