Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Killing processes

Reply
Thread Tools

Killing processes

 
 
hepp
Guest
Posts: n/a
 
      08-30-2004
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?
 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      08-30-2004
hepp wrote:
> 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.

> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Killing Threads & Processes on Windows x1 Ruby 15 11-10-2005 01:10 AM
problem killing nested Runtime.getRuntime().exec() processes bugbear Java 1 11-04-2005 12:11 PM
Listing/killing processes on IIS6.... Stu ASP .Net 2 08-02-2005 02:39 PM
Killing processes in CatOS Arnold Nipper Cisco 0 01-12-2005 05:33 PM
killing processes on win xp Andrei Python 1 02-13-2004 01:18 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57