Skip to contentSkip to conversation

ps/top doesn't show the process on a smp kernel ;)

DISCUSSION [email protected] 1 participant 1 message Mar 28, 2004

lore
Share & tools
lore
#0 lore raw

Hello,
This is the simple program that I tried on a - 2.4.20-30.9smp #1 SMP Wed Feb
4 20:36:46 EST 2004 i686 i686 i386 GNU/Linux (kernel) machine.

The ps command doesn't show me the process. /proc/ shows that these process are present in the system. When I uncomment the call getpid(). Then it shows me the process. I am not able to understand this behavior and I hope this is the right place to post this question/bug.

<snip>

#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>

int main()

{
    int i = 3;
    pid_t pid, pidarr[3];

    for(i = 0; i < 3;i ++) {
        if ( (pid = fork()) == 0) {
            while(1){
                /* getpid(); */
            }
        }
        pidarr[i] = pid;
    }
    for(i = 0; i < 3;i ++) {
        waitpid(pidarr[i], NULL, 0);
    }
    return 0;
}

</snip>