Windows - use task manager. If you can't see it on the processes tab, View/Select columns/PID on the. If you use procexp (download from MS) it will give you the processes in a tree so you can see the hierarchy.
Someone told me the following solution, I think this is what I am looking for.
Anyway thanks for your responses.
Mack
> I've been working on ZipOMatic lately, but now that I'm
> close to finishing it, I don't know how to kill the zip process,
> having started it with popen().
>
> It does a lot, but as of yet, no zipping:
>
>
> I need to open a process (or multiple ones), read it's output,
> kill off the process if the user presses Stop, or otherwise wait
> for it to terminate.
>
> And it needs to be thread-safe, so, IIRC, no fork()'ing.
> (there will be BLoopers around)
popen() use fork()
However, the issue there is to get the forked process team id, so that you can kill it or wait his end.
Here's my own popen() implementation, called my_popen() ;-) :
-----8<--------------------------------
static FILE * my_popen
(
Arguments & args,
const char * type,
long * tid
)
{
int p[2];
FILE * fp;
if (*type != 'r' && *type != 'w')
return NULL;
if (pipe(p) < 0)
return NULL;
if ((*tid = fork()) > 0) { /* then we are the parent */
if (*type == 'r') {
close(p[1]);
fp = fdopen(p[0], type);
} else {
close(p[0]);
fp = fdopen(p[1], type);
}
return fp;
} else if (*tid == 0) { /* we're the child */
/* make our thread id the process group leader */
setpgid(0, 0);
if (*type == 'r') {
fflush(stdout);
fflush(stderr);
close(1);
if (dup(p[1]) < 0)
perror("dup of write side of pipe failed");
close(2);
if (dup(p[1]) < 0)
perror("dup of write side of pipe failed");
} else {
close(0);
if (dup(p[0]) < 0)
perror("dup of read side of pipe failed");
}
close(p[0]); /* close since we dup()'ed what we needed */
close(p[1]);
execve(args[0], args, environ);
printf("my_popen(): execve(%s) failed!\n", args[0]);
} else { /* we're having major problems... */
close(p[0]);
close(p[1]);
printf("my_popen(): fork() failure!\n");
}
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.