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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:52:38+00:00 2026-05-10T19:52:38+00:00

I am writing an application which blocks on input from two istreams . Reading

  • 0

I am writing an application which blocks on input from two istreams.

Reading from either istream is a synchronous (blocking) call, so, I decided to create two Boost::threads to do the reading.

Either one of these threads can get to the ‘end’ (based on some input received), and once the ‘end’ is reached, both input streams stop receiving. Unfortunately, I cannot know which will do so.

Thus, I cannot join() on both threads, because only one thread (cannot be predetermined which one) will actually return (unblock).

I must somehow force the other to exit, but it is blocked waiting for input, so it cannot itself decide it is time to return (condition variables or what not).

Is their a way to either:

  • Send a signal a boost::thread, or
  • Force an istream to ‘fail’, or
  • Kill a Boost::thread?

Note:

  • One of the istreams is cin
  • I am trying to restart the process, so I cannot close the input streams in a way that prohibits reseting them.

Edit:

  • I do know when the ‘end’ is reached, and I do know which thread has successfully finished, and which needs to be killed. Its the killing I need to figure out (or a different strategy for reading from an istream).
  • I need both threads to exit and cleanup properly 🙁

Thanks!

  • 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-10T19:52:39+00:00Added an answer on May 10, 2026 at 7:52 pm

    I don’t think there is a way to do it cross platform, but pthread_cancel should be what you are looking for. With a boost thread you can get the native_handle from a thread, and call pthread_cancel on it.

    In addition a better way might be to use the boost asio equivalent of a select call on multiple files. That way one thread will be blocked waiting for the input, but it could come from either input stream. I don’t know how easy it is to do something like this with iostreams though.

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

Sidebar

Ask A Question

Stats

  • Questions 61k
  • Answers 61k
  • 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
  • added an answer I don't think there's a right or wrong answer here,… May 11, 2026 at 9:53 am
  • added an answer I just tried this javascript:(function(d) { d.createStyleSheet().cssText='* {color:blue !important;}' })(document);… May 11, 2026 at 9:53 am
  • added an answer You can register type aliases either in app.config/web.config: <configSections> <sectionGroup… May 11, 2026 at 9:53 am

Related Questions

I am writing an application which blocks on input from two istreams . Reading
I am in the process of writing an application which, among other functionality, generates
I am writing an application that downloads large files in the background. All clients
I am writing an application that needs to bring window of an external app
I am writing an application that if the user hits back, it may resend
I am writing an application in Java for the desktop using the Eclipse SWT
I am writing an application and I would like to be able to display
I am writing an application where I will be accessing the database from django
I am writing an application using labview and need to use external code. I
I am writing an application where all the request to the internet should go

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.