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 181353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:44:55+00:00 2026-05-11T14:44:55+00:00

I have two separate processes: a C program that outputs comma separated values followed

  • 0

I have two separate processes: a C program that outputs comma separated values followed by a newline every second, and a Perl program that accepts data (in the same format) and processes this data.

The C program outputs (via printf) values as such:

1, 2, 3, 4, 5, 6   7, 8, 9, 10, 11, 12   ... 

The Perl program sits in an infinite loop waiting on a line basis for STDIN in order to process this data:

while ($line = <STDIN>) {     chomp($line) # Line should now read '1,2,3,4,5,6'     # Process data } 

I want these two processes to communicate in real time. Standard bash pipes do not work (e.g. process1 | process2) because the Perl program waits for the first program to finish before processing the input.

Does anyone have any ideas, suggestions, or insightd as to a solution to this problem? Thank you in advance!

  • 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. 2026-05-11T14:44:56+00:00Added an answer on May 11, 2026 at 2:44 pm

    Pipes should be fine for this; you just need to control when the output of your C program is flushed to make it available to the perl script incrementally. You can do this in the C program using fflush(), which will force the buffer from your C program to be pushed out so the perl program can read it.

    There is nothing inherent about pipes that would cause the perl program to wait for the C program to finish writing before processing its output. Your perl program is written so that it processes STDIN one line at a time:

    while ($line = <STDIN>) { ... } 

    <> in this context reads one line from STDIN, but if there’s not one available it will block until one is. A call to fflush() from the C program will make this happen.

    Take a look at the Wikipedia article on Pipelines. The implementation section gives a brief description of how pipes are buffered, which should help you understand how your processes communicate. Pipes do allow concurrency between processes, and processes reading from and writing to pipes are managed by the scheduler just like other processes. Your problem here is with the buffering.

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

Sidebar

Ask A Question

Stats

  • Questions 114k
  • Answers 114k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There's a book for you: Working Effectively with Legacy Code… May 11, 2026 at 10:12 pm
  • Editorial Team
    Editorial Team added an answer The type cast is usually only needed if you're using… May 11, 2026 at 10:12 pm
  • Editorial Team
    Editorial Team added an answer EntryFormSet = modelformset_factory(Entry, form=EntryForm) May 11, 2026 at 10:12 pm

Related Questions

I can understand how one can write a program that uses multiple processes or
I have an interesting design problem and I was hoping you all could make
I'm new to javascript, my problem is effectively: I have a php page that
I am trying to understand if I really have any case for using git/mercurial.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.