LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   A problem with threads creates 300+ zombie processes (https://www.linuxquestions.org/questions/programming-9/a-problem-with-threads-creates-300-zombie-processes-387011/)

zahadumy 11-27-2005 03:00 PM

A problem with threads creates 300+ zombie processes
 
I have a problem with 4 threads (I think it doesn't matter what I'm trying to do) and for each thread I call pthread_join. My problem is it makes 300+ zombie processes and after the program finishes, I have no more zombie processes, so I suppose it kills all of them somehow. The point is the problem works fine on my computer, but I'm a student and this is one of my homeworks, and I have to show this problem to a teacher at school, and I know we have there a 100 processes limit, and it won't work there.
In my thread function I call a popen like this:
Code:

    strcpy (s, "ps -axuf 2>/dev/null | grep ");
    strcat (s, a->nume_user);
    f = popen (s, "r");

I know it's not recommended to redirect the standard output or error and to make pipe linking within a popen, but I did it before and it worked fine. Could it be this? Do you have any idea why this happens?

zahadumy 11-27-2005 08:15 PM

Problem solved. This happened because I forgot this:
Code:

pclose(f);


All times are GMT -5. The time now is 12:04 PM.