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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T09:13:51+00:00 2026-05-16T09:13:51+00:00

Given all the options to have processes or threads interact with each other (locks,

  • 0

Given all the options to have processes or threads interact with each other (locks, mutex, semaphores, message queues, shared memory, etc), I’m a bit lost about what’s best to do what I want.

I want several processes to wait for a certain event to happen. That is, I want them to block either until

  1. a certain timeout is reached, or
  2. a certain event is triggered by another process.

At any time, there can be an arbitrary number of such waiting processes and when the wake-up event happens, all of them must wake up, not just one.

And the one restriction that probably makes this much harder is: It has to be PHP and it must also work from mod_php running in apache.

  • 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-05-16T09:13:52+00:00Added an answer on May 16, 2026 at 9:13 am

    Well, it’s a bit "hacky", but you could do this with sockets. It really depends on what you’re trying to do… I really wonder if you actually need this kind of system (rather than trying to simplify the processes to where they don’t need IPC at all)…

    Create a "listener" deamon that does nothing but accept socket connections and put them in a queue. It would run socket_select waiting for either a new connection, or data to be written to the sockets. If data was written, it writes that data to all of its active connections then closes them and starts over. If a new connection is received, it puts it in the queue and then goes back to selecting…

    So then in your "child", all you need to do is connect to the master, set blocking socket_set_block($sock), and then set your timeout:

    socket_set_option(
        $sock,
        SOL_SOCKET,  // socket level
        SO_SNDTIMEO, // timeout option
        array(
            "sec"=>10, // Timeout in seconds
            "usec"=>0  // I assume timeout in microseconds
        )
    );
    

    Then, simply read from the socket (socket_read($sock)). It’ll block for up to the timeout you set or until the "master" writes back to it. After passing that call, just close the socket and continue on doing what you want to do…

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

Sidebar

Related Questions

have a database with a list of business leads. They are all given a
Given all the holy wars surrounding various code formatting styles, and many companies' strict
You are given all the prime factors of a number, along with their multiplicities
Having been given the all clear to move code from my Page_Loaded method to
Given an HTML page I would like to get all the 'x' files that
I followed all the steps given in this blog. When i am trying to
Given a package, how can I automatically find all its sub-packages?
Given a web URL, I want to detect all the links in a WEBSITE
Given a word W, I want to find all words containing the letters in
When displaying all articles of a specific month (given through the urls like this

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.