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_Opt ions* 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(PRO CESS_ALL_ACCESS , PM_FALSE,
pid);
DuplicateHandle (GetCurrentProc ess(), hTmpFile, procHandle,
&hTmpDupFile , 0, PM_FALSE, DUPLICATE_SAME_ ACCESS);
procOptions->setHandles(ACE _INVALID_HANDLE ,
(ACE_HANDLE)hTm pDupFile, (ACE_HANDLE)hTm pDupFile);
SetStdHandle(ST D_OUTPUT_HANDLE , hTmpDupFile);
SetStdHandle(ST D_ERROR_HANDLE, hTmpDupFile);
CloseHandle(pro cHandle);
}
ACEOS::close(hT mpFile);
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 3506
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.comwrot e:
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_Opt ions* 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(PRO CESS_ALL_ACCESS , PM_FALSE,
pid);
DuplicateHandle (GetCurrentProc ess(), hTmpFile, procHandle,
&hTmpDupFile , 0, PM_FALSE, DUPLICATE_SAME_ ACCESS);
procOptions->setHandles(ACE _INVALID_HANDLE ,
(ACE_HANDLE)hTm pDupFile, (ACE_HANDLE)hTm pDupFile);
SetStdHandle(ST D_OUTPUT_HANDLE , hTmpDupFile);
SetStdHandle(ST D_ERROR_HANDLE, hTmpDupFile);
CloseHandle(pro cHandle);
}
ACEOS::close(hT mpFile);
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.program mer.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 application (VB.NET) will start a process,
redirect its stdout and capture that process' output, displaying it in a
window.
I've written a component for this, and a test application for the component.
It allows me to specify a command to execute,...
|
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 application (VB.NET) will start a process,
redirect its stdout and capture that process' output, displaying it in a
window.
I've written a component for this, and a test application for the component.
It allows me to specify a command to execute,...
|
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 greatly appreciated.
Thanks,
Sri
|
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 its output, but not (in this
case) "nasm -v" , which displays version information.
whats happening?
slightly modified MS code:
Dim myProcessStartInfo As New ProcessStartInfo("c:\nasm\nasm", "-v")
myProcessStartInfo.UseShellExecute = False
|
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 of buffer space.
Once I start reading the stdout file returned by os.popen2 then the
process resumes. I know that I could just specify > /dev/null when
starting the process but I'd like to know if there is a way to start a
process using os.popen2...
| |
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 = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# Wait for the process to return
|
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 use. In fact I
don't even know if it is possible! I've heard something about PIPE and
popen...is this what I need? How can I use them? It is very important
for me that I could take the output in real-time.
Thanks for the help!
Massi
|
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 capture the results of the compile and
display them in a RichTextBox. The problem I'm having is that when I
intentionally introduce an error in the C code I'm compiling, I can't read
the error output in my C# program. I've tried redirecting both...
|
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 best regards,
Wilbert Berendsen
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |