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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:55:54+00:00 2026-06-10T22:55:54+00:00

I writing my first OS X command line program which is a server style

  • 0

I writing my first OS X command line program which is a server style program. It’s job is to process various information and respond to other events.

I have the following code in my main.m

int main(int argc, const char * argv[]) {
    @autoreleasepool {

        PIPieman *pieman = [[[PIPieman alloc] init] autorelease];
        [pieman start];

        NSRunLoop *loop = [NSRunLoop currentRunLoop];
        while (!pieman.finished && [loop runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]);

    }
    return 0;
}

I got this code from various documents and the basic idea is that once pieman.finished is set to YES, that the program then exits.

The problem I have is that the flag is being set by code inside pieman, but the run loop is not being triggered, so the program does not exit. I’ve been looking for ways to trigger the run loop and there seem to be a variety, but none that feel like a good solution. For example I could reduce the beforeDate: to a few seconds to cause periodic triggering of the run loop.

My preference would be that something triggers the run loop on the change of the finished boolean value.

Any suggestions?

  • 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-10T22:55:56+00:00Added an answer on June 10, 2026 at 10:55 pm

    You need to tell the run loop to return from runMode:beforeDate:. The NSRunLoop class doesn’t define a message to do that, but NSRunLoop is built on CFRunLoop, and the CFRunLoopStop function does what you need.

    @implementation PIPieman
    
    ...
    
    - (void)setFinished:(BOOL)finished {
        _finished = finished;
        CFRunLoopStop(CFRunLoopGetMain());
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing my first batch file, and as I've never used Windows Command Line
I just finished writing my very first command-line tool in Objective-C, compiled it, and
I'm writing a wrapper around the ssh command line client. After the first positional
I am writing a contact management program. I know how to read command-line arguments,
I am in the process of writing a PHP command line script to convert
I am writing a program that takes one action if the command line contains
Basically, I'm writing a Java Command-line application which accept parameter from user by readLine.
I'm writing a small command-line program that asks the user for polynomials in the
Im new to python programming.Im writing a simple command line based twitter app,and i
I'm writing a small Ruby command-line application that uses fileutils from the standard library

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.