Why does my child process begin on the first line of the main? When I run my program, "Hello There" will print twice. The child process should start on the line after the fork, am I right?
int main(){ printf("Hello There!"); pid_t PID; PID = fork(); if(PID == 0){ //Child } else{ //parent } }
This is a huge problem for me, because in my real program I am making a private file with mmap before fork. And because of this, what happens to me, the parent and the child have different personal files.
Calling NOT twice ... This is an optical illusion! :)
... STDOUT , \n, , , , ( fork ( )) .
\n, printf :
printf("Hello There!\n");
.
:
printf("Hello There!"); fflush(stdout);
Source: https://habr.com/ru/post/1613041/More articles:Speeding up data tables. - rBootstrap 4 responsive navbar that crashes with xs width? - twitter-bootstrap-4React Native Navigator - not redrawing component when data changes in passProps? - react-nativeΠΠ°ΠΌΠ΅Π½ΠΈΡΡ ΠΏΠΎΠ·ΠΈΡΠΈΡ ΠΏΠ΅ΡΠ΅Π·Π°Π³ΡΡΠ·ΠΊΠΈ ΠΊΠΎΠΌΠΏΠΎΠ½Π΅Π½ΡΠ° Π·Π°Π³ΡΡΠ·ΠΊΠΈ (popover) Π°Π²ΡΠΎΠΌΠ°ΡΠΈΡΠ΅ΡΠΊΠΈ - javascriptDjango + S3 + Pandas - ΠΠ°ΠΊ ΡΠΎΡ ΡΠ°Π½ΠΈΡΡ ΡΡΠ΅ΠΉΠΌ Π΄Π°Π½Π½ΡΡ Π½Π° Π²Π΅Π΄ΡΠ΅ S3? - pythonRedux: Π΄Π΅ΠΉΡΡΠ²ΠΈΠ΅ ΠΊΠΎΠ½Π΄ΠΈΡΠΈΠΎΠ½Π΅ΡΠ° Π½Π° ΡΠΎΡΡΠΎΡΠ½ΠΈΠ΅ - reactjsAttempting to edit a Wix HTML website - javascriptBuilding a cross-compiler - compiling gcc errors - cFormsAppCompatActivity ΠΈ MasterDetailPage: Π½Π΅Ρ ΠΏΠ°Π½Π΅Π»ΠΈ ΠΈΠ½ΡΡΡΡΠΌΠ΅Π½ΡΠΎΠ² - androidTCP Dead Line Detection Definition - cAll Articles