handle system function in case of hang
by linxbee from LinuxQuestions.org on (#59T0M)
I am using below program to launch another process using system function, i know it returns -1 in case we are not able to create process and not able to get the return status of child.
I wonder , in case if my "someprocess" hangs , what is the behavior, how to handle such scenario?
Code:#define SOMEPROCESS "/home/user/someprocess"
int main()
{
int ret = -1;
ret = system(SOMEPROCESS);
if( ret == -1 )
{
printf("problem in process execution\n");
}
else
{
printf("process execution success \n");
}
return 0;
}


I wonder , in case if my "someprocess" hangs , what is the behavior, how to handle such scenario?
Code:#define SOMEPROCESS "/home/user/someprocess"
int main()
{
int ret = -1;
ret = system(SOMEPROCESS);
if( ret == -1 )
{
printf("problem in process execution\n");
}
else
{
printf("process execution success \n");
}
return 0;
}