Wie wollen Sie töten zombie-Prozess mittels wait()

Habe ich diesen code erfordert, dass ein Elternteil zu Gabel 3 Kinder.

  • Woher wissen Sie, (und) wo die "wait()" Anweisung zu töten

    zombie-Prozesse?

  • Was ist der Befehl, um zombie-Prozesse wenn Sie Linux
    virtual box?

    main(){
    
     pid_t child;
     printf("-----------------------------------\n");
     about("Parent");
     printf("Now ..  Forking !!\n");
     child = fork();
     int i=0;
    
     for (i=0; i<3; i++){
        if (child < 0) {
            perror ("Unable to fork");
            break;
        } 
        else if (child == 0){
            printf ("creating child #%d\n", (i+1));
            about ("Child");
            break;
        }
    
        else{
            child = fork();
        }
      } 
    }       
    
    void about(char * msg){
    
     pid_t me;
     pid_t oldone;
    
     me = getpid();
     oldone = getppid();
    
     printf("***[%s] PID = %d   PPID = %d.\n", msg, me, oldone);
    
    }
Wenn ich davon ausgehen - ich würde warten, (3) nach dem child=fork() im else-Anweisung. Ich bin zwar nicht fließend mit zombie-Prozesse oder linux, so bin ich mir auch nicht sicher, wie Sie Sie anzeigen, die zombie-Prozesse

InformationsquelleAutor mudwomp | 2015-02-11

Schreibe einen Kommentar