system ("ls") call hangs

Hi,
I created a thread using pthread_create call with proper ID,attributes etc.
Also I tried executing the system() function before and after the creation of this thread.The system() function call before the thread creation is executed perfectly.But the one after the thread creation hangs indefinitely. The thread that I have created is a for timer task and it runs infinitely. Once the timer(child) thread is up and running, the system() function call in the parent thread hangs.

I am presenting the code snippet here,

173 pthread_mutex_lock (&(pTsk->TskMutex));/* Create the qnx thread. */ 174 system("echo \"**************174********************\""); 175 if (pthread_create (&(pTsk->ThrId), &Attr, OsixTskWrapper, (void *) pTsk)) 176 { 177 pthread_mutex_unlock (&(pTsk->TskMutex)); 178 179 pthread_mutex_destroy (&(pTsk->TskMutex)); 180 pthread_mutex_destroy (&(pTsk->EvtMutex)); 181 pthread_cond_destroy (&(pTsk->EvtCond)); 182 183 OsixRscDel (OSIX_TSK, u4Idx); 184 return (OSIX_FAILURE); 185 } 186 187 /* The OSIX task has been fully created. Now let the thread run. */ 188 pthread_mutex_unlock (&(pTsk->TskMutex)); 189 system("echo \"**************189********************\"");

The process hangs at line number 189.
Please guide me on this. Why system function call is hanging ?

you might want to do this

pthread_attr_setdetachstate( &Attr, PTHREAD_CREATE_DETACHED);
before calling pthread_create()

I did that too Mathew.
It is done just above the portion of code I have presented. So the thread is dettached.

karthiktceit,

The thread that I have created is a for timer task and it runs infinitely

What does this mean?

If your other thread is an infinite loop at a higher priority and never gives up the CPU it could simply be that your main thread is starved for CPU time in which case it will never be able to execute the next line of code.

Also, why are you using system calls to debug your app instead of simple printf’s?

Tim

why don’t you try the system call with & sign like below
sysetm(“echo **********************”&");

How about
fprintf(stderr,"************************\n");