0

I am testing create&kill a process by *g_spawn_async_with_pipes()* in windows

Here is my code:

# argv is: ping xxx -t
GSpawnFlags flags = (GSpawnFlags)(G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH);
GError *error = NULL;
GPid pid;
gint stdio[3];
g_spawn_async_with_pipes(NULL, argv, NULL, flags, NULL, NULL, 
&pid, &stdio[0], &stdio[1], &stdio[2], &error);
// ...# here i can read info from stdio[1]
g_spawn_close_pid(pid); # this does nothing

It doesn't works

I find that: the pid return by g_spawn_async_with_pipes != the pid in windows task management

How to kill the pid using C/C++?

Jacob
  • 41
  • 4

1 Answers1

0

I have find the answer:

use kill() kill the pid in linux

use TerminateProcess() kill the pid in windows, in windows the pid is the HANDLE

Jacob
  • 41
  • 4