I have multi thread application in which I'm creating a thread like this:
int main(int argc,char *argv[])
{
pthread_t thread_id[argc-1];
int i;
struct parameter thread_data[argc-1];
int status;
for(i=0;i<argc-1;i++)
{
thread_data[i].ip_filename = argv[i+1];
strcpy (thread_data[i].op_filename,argv[i+1]);
strcat (thread_data[i].op_filename,".h264");
}
for(i=0;i<argc-1;i++)
{
pthread_create (&thread_id[i], NULL , &thread_function, &thread_data[i]);
}
}
Now in the thread function, I want to redirect stderr
& stdout
in one separate file as per thread. Something like a thread log file.
How can I do so?
Edit:
If thread specific prints can be displayed on different terminal..? I mean if there are 2 threads then it opens 2 terminals & prints each threads data on different terminals.