为什么父进程中 把sleep放到35行就不执行子进程的逻辑了呢 放到32行就很正常

 #include <stdio.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<arpa/inet.h>
#include<signal.h>
#include<unistd.h>
#include<stdlib.h>
#include<assert.h>
#include<string.h>
#include<errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int main(int argc , char **argv)
{
    int fd[2] , n ;
    char c ; 
    pid_t childpid ; 
    pipe(fd);
#if 1
    if((childpid = fork()) == 0)
    {
        if((n = read(fd[0],&c ,1))!= 1)
            perror("no data\n");
        printf("child %c %d %d \n",c ,fd[0],fd[1]);
        write(fd[1],"c",1);
        exit(0);
    }
#endif
    write(fd[1],"p",1);//31
    if((n = read(fd[0],&c ,1))!= 1)
        perror("no data\n");
    printf("parent %c %d  %d \n",c,fd[0],fd[1]);
    sleep(6);//35
    exit(0);

}

sleep会阻塞住当前线程,而管道是异步获取的,你单步调试下