1

linux process with status 'D' mean TASK_UNINTERRUPTIBLE, so I write a programer to test it on Ubuntu 16.04

My code:

#include <unistd.h>
#include <iostream>
using namespace std;

int main(void) {
    pid_t  pid = vfork();
    if (pid == -1) {
        cout<<"for error"<<endl;
    } else if (pid == 0) {
        cout<<"this child is "<<getpid()<<endl;
        sleep(1000);
    } else {
        cout<<"this parent is "<<getpid()<<endl;
    }
    return 0;
}

after I run the programmer, the status of the parent process is 'D'

When I use kill command to kill the parent process, the parent process was be killed successfully, so anything wrong in my code ?

Thanks very much !!!

Liu Tom
  • 397
  • 2
  • 9

0 Answers0