-
process monitor
hi
i am writing a simple application which start 2 threads in it.
i am writing one more application that will monitor this application if it is alive or killed. if killed i need to restart it.
in /proc/<process pid>/ i will get all the information regarding that process.
as i am writing a c program how can i get the process pid so that i can search in /proc. example code will appreciated
-
Hi Maggi,
Please find the below sample code to run unix command & get the result into output string
-----------------------------------------------------------------------------------------------------------
int run_unix_command(const char *command,char *output)
{
FILE *file;
char line[512];
int ret = -1;
file = popen(command , "r");
if (file != NULL)
{
if (fgets(line , sizeof ( line ) , file) == NULL)
{
ret = -1
}
else
{
strcpy(output,line);
ret = 1;
}
pclose(file);
}
return ret;
}
----------------------------------------------------------------------------------------------
Lakshika:):):):)
“A community site where you can try Open Source software for free. right in your browser.”
www.click2try.com
-
Thanks lakshika,
It is working for me and i am able to get he PID for that