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

  • SEARCH
  • Home
  • 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 8453305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:44:11+00:00 2026-06-10T11:44:11+00:00

so I am new to inter-process communications and processes in linux, so I really

  • 0

so I am new to inter-process communications and processes in linux, so I really cannot figure out what the problem is. The following program I wrote is the same problem I am having on a homework assignment consisting of using pipes condensed down. It is basically sending one character from the child to the parent, but it does not print out the character.
it print out:

hello from child
sending a
hello from parent
trying to receive...
received: reaping child

where on the third line it should say

received: a

Any answers are appreciated, and also if you have any helpful criticism of anything else in the program. Thanks everyone

#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>
#include <stdlib.h>


int main(int argc, char* argv[])
{
    pid_t pid = fork();
    int comm[2];

    pipe(comm);

if (pid == 0)
{
    char send = 'a';
    int check;
    close(comm[0]);
    printf("hello from child\n");
    printf("sending %c\n", send);
    check =  write(comm[1], &send, 1);
    printf("%d\n", check);
    exit(1);
}
else if (pid > 0)
{
    char get = ' ';
    int check;
    close(comm[1]);
    printf("hello from parent\n");
    printf("trying to receive...\n");
    read(comm[0], &get, 2);
    printf("received: %c\n", get);
    printf("reaping child\n");
    wait(NULL);
    return 0;
}

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-10T11:44:13+00:00Added an answer on June 10, 2026 at 11:44 am

    You got the pipe and the fork in the wrong order! Your process forks, then both processes call pipe, so 2 separate pipes are being created. The one you’re writing into has nobody reading it, and the one you’re reading from had nothing written to it.

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

Sidebar

Related Questions

I am using IO::Socket::INET to create inter-process communication in my program. I need to
I am new to inter process communication and need some help. I want to
I am trying to figure out what process locks a file using the class
I read that: Object sync = new Object(); /* inter to monitor */ try
Given the following code: Hashtable main = new Hashtable(); Hashtable inner = new Hashtable();
At work we are inte process of starting development on a new web-based product.
I'm searching for a light-weight, fast and easy way to handle Inter Process Communication
I am using distributed object for inter process communication. I am running one server
I am new to LINQ and have become stumped on the translating the following
I have what seems to be a fairly common inter-process communication requirement - a

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.