#include int main() { char buf[80]; fork(); // both parent and child will read from the // same terminal - it's undefined who's get // the input. // (And, you need to type ^D twice to exit // both programs.) while (fgets(buf, sizeof buf, stdin)) { printf("pid %d: ", getpid()); fputs(buf, stdout); } }