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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:18:45+00:00 2026-05-29T04:18:45+00:00

I’m looking for the simplest or most appropriate way on Mac OS X to

  • 0

I’m looking for the simplest or most appropriate way on Mac OS X to simply “signal” or notify one process from another. Coming from a Windows background this could be achieved using something like the following.

In Process A:

// create named event
hCreatedEvent = CreateEvent(NULL, TRUE, FALSE, "MyUniqueNamedEvent");

// wait for it to be signalled
WaitForSingleObject(hCreatedEvent, INFINITE);

and then in Process B:

// open the existing named event
hOpenedEvent = OpenEvent(EVENT_ALL_ACCESS, FALSE, "MyUniqueNamedEvent");

// signal it
SetEvent(hOpenedEvent);

So when the SetEvent call in Process B is executed, Process A would break out from WaitForSingleObject and do some work.

I don’t need to actually send any data so I’ve ruled out things like Named Pipes (FIFO’s) or sockets etc. as being a bit overkill (I’ve taken a look at this similar question, but as they need to send data, my question is slightly different). Equally, I won’t know the PID of the other process (which is why I need some kind of shared object) so I can’t use anything that would require that.

So far on my shortlist is:

  • POSIX Semaphores – using sem_open, sem_wait and sem_post to create/open, wait on and signal the event respectively. Appears fairly straighforward to use.
  • The BSD notify(3) functions – appears fairly straightforward to use, if not a little clunky to consume notifications.
  • The NSDistributedNotificationCenter or CFNotificationCenter functions – appears the most “Mac like” way of doing things and fairly straightforward. However, my code may needs to run as a dylib and according to this unanswered question, that may not work for me.

So, does anyone have any advice/tips/horror stories having used any of the above, or even more appropriate alternatives I haven’t thought of to achieve what I want?

  • 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-29T04:18:46+00:00Added an answer on May 29, 2026 at 4:18 am

    So after a bit more digging I finally decided to go down the POSIX semaphores route, which seems to work for me, like so:

    In Process A (waiting on the semaphore):

    // create semaphore, fail if already exists
    sem_t *sem = sem_open("MyUniqueSemaphore", O_CREAT | O_EXCL, 0666, 0);
    if (sem != SEM_FAILED)
    {
        // wait on semaphore
        if (sem_wait(sem) == 0)
        {
            // semaphore signalled!
        }
    
        // close our "handle" to the semaphore and remove it from the system
        sem_close(sem);
        sem_unlink("MyUniqueSemaphore");
    }
    

    Then in Process B (signalling the semaphore):

    // open the existing semaphore created in process A
    sem_t *sem = sem_open("MyUniqueSemaphore", 0);
    if (sem != SEM_FAILED)
    {
        // "signal" it
        sem_post(sem);
    
        // close our "handle" to the semaphore
        sem_close(sem);
    }
    

    The semaphore seems to also be an “auto reset” type (in Windows parlance) so reverts back to unsignalled once it has been signalled.

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

Sidebar

Related Questions

I am currently running into a problem where an element is coming back from
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.