fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. // your code goes here
  5. return 0;
  6. }
  7.  
Success #stdin #stdout 0s 5316KB
stdin
#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>

int main() {
    int pid;

    pid = fork();
    if (pid == 0) {
        printf("b\n");  // 加\n,触发缓冲刷新
        return 0;
    }

    pid = fork();
    if (pid == 0) {
        printf("c\n");  // 加\n
        return 0;
    }

    wait(NULL);
    wait(NULL);
    printf("a\n");  // 加\n

    return 0;
}
stdout
Standard output is empty