Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7797703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:46:09+00:00 2026-06-01T23:46:09+00:00

I am studying about system programming system calls. I have a code block in

  • 0

I am studying about system programming system calls. I have a code block in my assignment (given below). The question asks me to how many A,B or C will be printed. My question is what is the meaning of if(pid == 0)? I guess if(pid == 0) means false, so I analyse that 2 x A and 2 x B will be printed. Am I write or? Second question is does pid2 = fork() executes main again?

int main()
{
  int pid,pid2;
  int i;
  pid = fork();
  printf("A\n");
  if (pid == 0)
    pid2=fork();
  if (pid2)
    printf("B\n");
  printf("C\n");
  return 0;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T23:46:11+00:00Added an answer on June 1, 2026 at 11:46 pm

    The fork system call is special. You call it once and it returns twice. Once in the child and once in the parent.

    In the parent it returns the pid of the child and in the child it returns 0. Thus, if (pid == 0) means “if this is the child“.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm studying about windows and DLL stuffs and I have some question about it.
I am studying Java concurrency right now. I have a question about synchronized and
While studying about JMX, I have seen one of the important feature of it
I have recently started studying about threads. I thought of starting from the beginning
I'm studying The C++ Programming Language from Bjarne Stroustrup and he talks about logical
I have been studying DDD in-depth on my own time; reading everything about it
I am currently studying recursion in school, and I have trouble thinking about methods
I was studying the Kernel Architecture and its programming to get the idea about
While I was studying about shared library I read a statement Although the code
I am studying about operating systems(Silberscatz, Galvin et al). My programming experiences are limited

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.