Hi All
Does any one has idea about how to set stdout and stderr to a spawned
process?
I don't want to have all the handles of the parent process in the
child process but I want only one of it (handle to a file). If I
inherit all the handles of the parent process my application won't
work. So I am spawning a process without inheriting the handles but I
am inheriting environment variables. Later I take the PID of the
spawned process and using Openprocess() function I get the process
handle and I generate a duplicate file handle for the child process
with an existing file handle. Now I am trying to set STDOUT and STDERR
using SetStdHandle() function. The code I wrote is below:
ACE_Process_Options* procOptions;
procOptions->setCommandLine(m_sCommandLine);
ACE_HANDLE hTmpFile = ACE_OS::open(m_sStdOutErrFile, O_WRONLY|
O_CREAT);
HANDLE hTmpDupFile;
procOptions->setHandles(ACE_INVALID_HANDLE, hTmpFile,
hTmpFile);
pid = pOSMonitor->spawnProcess(m_pProcess, procOptions);
if (pid 0){
HANDLE procHandle = OpenProcess(PROCESS_ALL_ACCESS, PM_FALSE,
pid);
DuplicateHandle(GetCurrentProcess(), hTmpFile, procHandle,
&hTmpDupFile, 0, PM_FALSE, DUPLICATE_SAME_ACCESS);
procOptions->setHandles(ACE_INVALID_HANDLE,
(ACE_HANDLE)hTmpDupFile, (ACE_HANDLE)hTmpDupFile);
SetStdHandle(STD_OUTPUT_HANDLE, hTmpDupFile);
SetStdHandle(STD_ERROR_HANDLE, hTmpDupFile);
CloseHandle(procHandle);
}
ACEOS::close(hTmpFile);
But when I execute my application the standard output and standard
error are not written to the file pointed by the file handle
'hTmpDupFile'.
Am I missing anything here?
Thanks in advance
Subrahmanya 2 3459
subrahmanya wrote:
Hi All
Does any one has idea about how to set stdout and stderr to a spawned
process?
Since "spawning a process" is platform-specific, you should ask about
this in the newsgroup dedicated to your platform. Someone there does
undoubtedly have an idea...
[..]
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
On Apr 25, 7:36 am, subrahmanya <subrahmanya....@gmail.comwrote:
Hi All
Does any one has idea about how to set stdout and stderr to a spawned
process?
I don't want to have all the handles of the parent process in the
child process but I want only one of it (handle to a file). If I
inherit all the handles of the parent process my application won't
work. So I am spawning a process without inheriting the handles but I
am inheriting environment variables. Later I take the PID of the
spawned process and using Openprocess() function I get the process
handle and I generate a duplicate file handle for the child process
with an existing file handle. Now I am trying to set STDOUT and STDERR
using SetStdHandle() function. The code I wrote is below:
ACE_Process_Options* procOptions;
procOptions->setCommandLine(m_sCommandLine);
ACE_HANDLE hTmpFile = ACE_OS::open(m_sStdOutErrFile, O_WRONLY|
O_CREAT);
HANDLE hTmpDupFile;
procOptions->setHandles(ACE_INVALID_HANDLE, hTmpFile,
hTmpFile);
pid = pOSMonitor->spawnProcess(m_pProcess, procOptions);
if (pid 0){
HANDLE procHandle = OpenProcess(PROCESS_ALL_ACCESS, PM_FALSE,
pid);
DuplicateHandle(GetCurrentProcess(), hTmpFile, procHandle,
&hTmpDupFile, 0, PM_FALSE, DUPLICATE_SAME_ACCESS);
procOptions->setHandles(ACE_INVALID_HANDLE,
(ACE_HANDLE)hTmpDupFile, (ACE_HANDLE)hTmpDupFile);
SetStdHandle(STD_OUTPUT_HANDLE, hTmpDupFile);
SetStdHandle(STD_ERROR_HANDLE, hTmpDupFile);
CloseHandle(procHandle);
}
ACEOS::close(hTmpFile);
But when I execute my application the standard output and standard
error are not written to the file pointed by the file handle
'hTmpDupFile'.
Am I missing anything here?
Thanks in advance
Subrahmanya
Try asking in this group: comp.os.ms-windows.programmer.win32 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Oz |
last post by:
This is long. Bear with me, as I will really go through all the convoluted
stuff that shows there is a problem with streams (at least when used to
redirect stdout).
The basic idea is that my...
|
by: Oz |
last post by:
This is long. Bear with me, as I will really go through all the convoluted
stuff that shows there is a problem with streams (at least when used to
redirect stdout).
The basic idea is that my...
|
by: SG |
last post by:
Hello,
I'm using _execvpe (Win32 console project in VS.NET)
to spawn a child process. I would like to know if you
have any pointers on how to capture the child's STDOUT
and STDERR? Any help is...
|
by: Patrick Porter |
last post by:
Im trying to capture the stdout from running a process from within my app.
I've been dinking around using the code straight off the MS site. i can get
"ipconfig / all" (for example) to send back...
|
by: mikem76 |
last post by:
How do I automatically redirect stdout and stderr when using os.popen2
to start a long running process. If the process prints a lot of stuff
to stdout it will eventually stop because it runs out...
|
by: Christoph Haas |
last post by:
Evening,
I'm having trouble with running a process through Python 2.4's
subprocess module. Example code:
========================================================
def run(command):
run =...
|
by: Massi |
last post by:
Hi everyone! I'm writing a python script which uses a C-written dll. I
call the functions in the dll using ctypes, but I don't know how to
catch the output of the "printf" which the C functions...
|
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= |
last post by:
Hello,
I have a C# application in which I start another process which produces
output to stdout and stderr. In fact, that process is the uSoft VS2005 C/C++
compiler itself! I would like to...
|
by: Wilbert Berendsen |
last post by:
Hi,
using pty.spawn() it seems that stderr output of the spawned process is
directed to stdout. Is there a way to keep stderr separate and only direct
stdin and stdout to the pty?
TIA,
w...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |