A teenager asked me a question yesterday ,#include<stdio.h> int main() { fork(); fork(); fork(); printf("hello "); return 0; } Print a few hello, I got stuck .

And then I took a closer look fork function . Just look at the explanation on the Internet

One fork Produce an identical subprocess ,3 The last time I had one 8 A process , their stdout All the same as the original parent process , So the final output is on the terminal .

F(n)=2F(n-1),F(0)=1
therefore F(n)=2^3=8 It's easy to understand with a picture ·

fork Function of a point to learn more related articles

  1. UNIX Environment programming learning notes (19)—— Process management fork Deep learning of functions

    lienhua342014-10-07 stay “ Process control trilogy ” in , We have learned fork It's the first part of the trilogy , Used to create a new process . But what about fork Some of the more in-depth things we haven't covered yet , for example ,fork ...

  2. Linux—fork Function learning notes

    fork() function In the assignment statement pid = fork(); Before , Only one process is executing this code , But after this statement , It becomes two processes in execution , The code parts of the two processes are exactly the same .> In two processes , The one that existed before was ...

  3. UNIX Environment advanced programming learning notes ( Ten ) why fork Function has two different return values 【 turn 】

    from :http://blog.csdn.net/fool_duck/article/details/46917377 The following is based on linux 0.11 Description of the kernel . stay init/main.c The first 138 That's ok ...

  4. Process control fork function

    An existing process can call fork Function to create a new process . #include <unistd.h> pid_t fork( void ); Return value : Return... In child process 0, Return child process in parent process ID, Error return - ...

  5. &lt;UNIX Environment advanced programming &gt; File sharing and fork function

    UNIX The system supports sharing open files between different processes . The kernel using 3 A data structure represents opening a file , The relationship between them determines the impact of one process on another in file sharing . The kernel maintains 3 Tables , It's a schedule , File table and v Node table . As follows ...

  6. About fork( ) Function parent-child process return value problem

    fork() yes linux System call functions for sys_fork() The interface function provided to the user ,fork() Function will implement the interrupt int 0x80 And return the result to the user program . fork() The function definition of is in init ...

  7. Linux In the environment fork Functions and exec The use of function families

    Preface Contact Linux It's been months , In the past, all the great gods on the Internet said Windows It's the worst development platform , I always don't think so , But after this time of thinking , I do feel that Linux Development brings me a lot of convenience . Let's sum up learning ...

  8. About fork() Function function

    (1)    Let's take a look at an example : #include <unistd.h>; #include <sys/types.h>; main () {           pid_t pi ...

  9. Process management fork function

    fork Definition of function #include <unistd.h> #include <sys/types.h> pid_t fork(void); fork Function returns the... Of the child process in the parent process ...

Random recommendation

  1. hibernate note -- One of the caching mechanisms First level cache (session cache )

    First level cache : Also known as session cache , It and session Same life cycle , The cycle is very short . It's a transaction level cache : Or to Book and Category Take these two tables for example , We use code to observe the existence of a cache : Suppose now I'm going to check i ...

  2. Oracle Rac crs Can't start

    OS:ORACLE LINUX 5.7 DB:11.2.0.3 RAC:YES fault :1. Two node RAC, The nodes are linuxdb1.linuxdb2, Where nodes linuxdb2 The server is down , Can't start 2 ...

  3. PHP Picture file upload code sharing

    Under the share php Upload a piece of image file code , Pretty good . adopt PHP, You can upload files to the server . Add some image judgment , If you don't judge the type of the file, you can upload any file format . Yes, of course , It's not allowed to upload php file , And other programs ...

  4. SpringMVC( Two )

    Today, on the premise of the completed work , Finally, before going to bed SpringMVC and Mybatis Integrated ~~~ In fact, it's from the Internet ( Reference resources http://www.toutiao.com/a6332703083554324737/ ...

  5. Delphi use ADOquery Example of master-slave table ( turn )

    http://blog.csdn.net/kandy_zheng/article/details/1639184 stay sql server Of northwide Create a master table in create table s ...

  6. The view and URL To configure

    The view and URL To configure Introduction to the experiment In the last chapter, we showed you how to create a Django Project and launch Django Development server for . In this chapter you will learn to use Django Basic knowledge of creating dynamic web pages . meanwhile , It also teaches you how to set up an independent company on the local machine ...

  7. ntoskrnl The sign is in IDA Questions to see in

    The recent discovery x64 Of ntoskrnl.exe, If you are directly in IDA View in , There will be some functions IDA Not identified , such as

  8. Colleges and universities declare APP- Sprint the next day

    There was a second meeting today . One . Mission : Yesterday's task completed basic login registration, modify page layout . Today's task completes the basic framework of the login interface . Tomorrow's task login modification registration jump , Solve the problem of real machine running flashback . Two . Difficulties encountered : Login interface button layout location , Input ...

  9. MSBuild Command parameter

    Build a Visual Studio project or solution using MSBuild Command Line Arguments  Common command line parameters Detailed explanation : MSBuild ...

  10. docker swarm Build and service update

    One ,docker swarm What is it? Docker Swarm.Docker Machine And Docker Compose It's called Docker Three swordsmen Docker Swarm and Docker Compos ...