C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Killing processes

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
hepp
Guest





PostPosted: Mon Aug 30, 2004 7:45 pm    Post subject: Killing processes Reply with quote



I need to execute a system command, read the printouts from its output
stream and be able to kill the process when needed. Is there any way
to accomplish all this in C/C++?

First I tried to use popen to open a pipe to the process, but then I
can't kill it since it doesn't return the pid. The only thing I can do
is to close the output stream by using pclose, but it waits for the
process to finish so it's of no use.

One possible way to do it is to use popen to get access to the output
stream and then use system commands to find out its pid, but there got
to be a better way, doesn't it?
Back to top
Victor Bazarov
Guest





PostPosted: Mon Aug 30, 2004 7:57 pm    Post subject: Re: Killing processes Reply with quote



hepp wrote:
Quote:
I need to execute a system command, read the printouts from its output
stream and be able to kill the process when needed. Is there any way
to accomplish all this in C/C++?

No, but you can accomplish the first step by calling the 'system'
function. All other steps can be done using OS-specific means.

Quote:
First I tried to use popen to open a pipe to the process, but then I
can't kill it since it doesn't return the pid. The only thing I can do
is to close the output stream by using pclose, but it waits for the
process to finish so it's of no use.

One possible way to do it is to use popen to get access to the output
stream and then use system commands to find out its pid, but there got
to be a better way, doesn't it?

The better way is to use platform-specific functions to control processes.
However, they are OT here. Ask in a newsgroup for your platform/OS.

V

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.