Subj : Re: Problem with system() calls in a multithreaded program on HPUX To : comp.programming.threads,comp.sys.hp.hpux From : Stefaan A Eeckels Date : Mon Feb 14 2005 09:53 am On 13 Feb 2005 23:09:37 -0800 maheshkumarjha@gmail.com (Mahesh Kumar) wrote: > Can anyone suggest a possible reason for still hanging? Remember that the advice was to use fork()/exec() _AND_ to go single-threaded. The fork() functions suspend all threads in the process before they run. Threads that are already running and are in an uninterruptible wait inside the kernel cause the fork() to pause until they exit the uninterruptible wait. As a result, fork(), and your whole process, appears to be hung. Using fork() In a multithreaded process can result in interrupted blocking system calls - you should be prepared to handle EINTR errors. fork() per se isn't thread-safe, and requires TLC to mesh well with threads. If you really have to continue with your multi-threaded approach, read the popen(3) man page carefully. Notice where it says: | popen() and pclose() are thread-safe. These interfaces are not | async-cancel-safe. A cancellation point may occur when a thread is | executing popen() or pclose(). and consider whether your objectives cannot achieved through a less complex approach. Take care, -- Stefaan -- As complexity rises, precise statements lose meaning, and meaningful statements lose precision. -- Lotfi Zadeh .