fork() system call in c

前端 未结 5 1728
孤城傲影
孤城傲影 2021-01-01 06:17
    #include 
    #include 
    int main()
    {
       fork();
       fork() && fork() || fork();
       fork();

     printf         


        
5条回答
  •  醉酒成梦
    2021-01-01 06:39

    fork();
    

    fork system call returns an integer: the PID of the process in the parent process and 0 in the child process. If an error occurs, no process is created and -1 is returned.

    || and && are logical operators.

    If the result of the operator is know after the evaluation of their left operand, they are required to short-circuit (i.e., not evaluate the right operand):

    • for || operator its right operand is not evaluated if its left operand is != 0
    • for && operator its right operand is not evaluated if its leftt operand is == 0

提交回复
热议问题