View topic - system ("ls") call hangs

system ("ls") call hangs

anything that doesn't fit to other groups.

system ("ls") call hangs

Postby karthiktceit » Wed Feb 24, 2010 3:22 pm

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,
Code: Select all
   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 ?
karthiktceit
New Member
 
Posts: 3
Joined: Tue Jan 05, 2010 6:33 am

RE: system ("ls") call hangs

Postby jinma » Wed Feb 24, 2010 7:49 pm

you might want to do this

pthread_attr_setdetachstate( &Attr, PTHREAD_CREATE_DETACHED);
before calling pthread_create()
jinma
Senior Member
 
Posts: 428
Joined: Thu Oct 28, 2004 10:13 pm

RE: system ("ls") call hangs

Postby karthiktceit » Thu Feb 25, 2010 8:36 am

I did that too Mathew.
It is done just above the portion of code I have presented. So the thread is dettached.
karthiktceit
New Member
 
Posts: 3
Joined: Tue Jan 05, 2010 6:33 am

Postby Tim » Fri Feb 26, 2010 6:22 pm

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
Tim
Senior Member
 
Posts: 1466
Joined: Wed Mar 10, 2004 12:28 am

RE: system ("ls") call hangs

Postby jinma » Fri Feb 26, 2010 6:23 pm

why don't you try the system call with & sign like below
sysetm("echo \**********************\"&");
jinma
Senior Member
 
Posts: 428
Joined: Thu Oct 28, 2004 10:13 pm

RE: system ("ls") call hangs

Postby maschoen » Sat Feb 27, 2010 7:24 pm

How about
fprintf(stderr,"************************\n");
maschoen
QNX Master
 
Posts: 2715
Joined: Wed Jun 25, 2003 5:18 pm


Return to General Programming

Who is online

Users browsing this forum: No registered users and 2 guests

cron