Interrupt Shell Command

Hokay, so I execute commands and get the output like so:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
char buffer[1024];
string command("");

while(true)
{
	g_Client.Receive(command);

	if(command == "EXIT" || !g_Client.m_bConnected)
		break;

	FILE* pipe = _popen(command.c_str(), "r");

	while(fgets(buffer, 1024, pipe))
		g_Client.Send(buffer);

	_pclose(pipe);

	command = "";
}


Let's say I send the command "tree C:\" (or something similar that returns a large amount of data) and I want to stop the process (as if I'd pressed Ctrl + C) - how would I go about doing this? I've tried passing SIGINT to the signal function, messed around with pipe, fork, execl, etc... can't seem to get anything to work.

Anyone mind schooling me on how this is done correctly?
Last edited on
Anyone?
Topic archived. No new replies allowed.