Using system calls in GTK applications ...



Hi,

I'm writing a GTK+ appl. where I need to get a list of currently running
processes based on a search criteria specified by the user. I've tried
using both "system" and "execve" to get the results dumped into a file
(which I can process later) but the results are flushed on the stdout
instead. These commands work perfectly well on the terminal window.
Could somebody please help ! Code snippet :

int ret;
char *argv[4];
char **environ=NULL;
argv[0]="sh";
argv[1]="-c";
argv[2]="ps -eo pid,user,args | grep netscape > /tmp/abc";
argv[3]=0;
ret = execve("/bin/sh",argv,environ);

 OR simply :

ret = system("ps -eo pid,user,args | grep netscape > /tmp/abc");

Thanks for your time.
Regards,
Seema.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]