4
ทำไมบางครั้งโปรแกรมด้วย fork () บางครั้งก็พิมพ์ผลลัพธ์ออกมาหลาย ๆ ครั้ง?
ในโปรแกรม 1 Hello worldได้รับการพิมพ์เพียงครั้งเดียว แต่เมื่อฉันลบ \nและเรียกใช้ (โปรแกรม 2) ผลลัพธ์จะได้รับการพิมพ์ 8 ครั้ง ใครช่วยอธิบายความสำคัญของ\nที่นี่กับมันได้fork()อย่างไร โปรแกรม 1 #include <sys/types.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> int main() { printf("hello world...\n"); fork(); fork(); fork(); } เอาท์พุท 1: hello world... โปรแกรม 2 #include <sys/types.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> int main() { printf("hello world..."); …