• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
how to run NSApplicationMain() in child process?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

how to run NSApplicationMain() in child process?


  • Subject: how to run NSApplicationMain() in child process?
  • From: Ondrej Holecek <email@hidden>
  • Date: Wed, 08 May 2013 12:41:29 +0200

Hi,

I'm creating a picture viewer controlled from command-line (I call it
xqiv which sould be an equivalent to http://www.klografx.net/qiv/ on
linux). However, xqiv is slightly different.

You have to run xqiv-daemon, which is the window-based application
which handles global notifications sent by xqiv-command-line and
displays the image(s). My idea is to have just one application xqiv
which acts as both daemon and/or command-line tool together. If you
run xqiv and the deamon is not running yet it forks and run the
daemon. Parent would act as a commandline tool and child would be the
daemon which stay on background. Parent would sent a notification to
the forked child what image to display and exit. If the daemon is
already running, then fork is not needed and it would just sent the
notification.

The question is, how to force  NSApplicationMain() to run in child.

The basic idea is to do something like this:

if (already running) {
  return cmd_main(argc, argv);
} else {
    if (fork() == 0) {
        return NSApplicationMain(argc, (const char **)argv);
    } else {
        return cmd_main(argc, argv);
    }
}

The real code is there: http://pastebin.com/7LD2dPK8

When I run NSApplicationMain() in child process, it simply does
nothing. What's wrong?

I have already functional application there:
https://github.com/smrt28/xqiv

It is functional but daemon and command-line tool are two applications.

let me note I'm the beginner in objc/cocoa development and this is my
very first cocoa application.

thanks,

Ondrej
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: how to run NSApplicationMain() in child process?
      • From: Ken Thomases <email@hidden>
    • Re: how to run NSApplicationMain() in child process?
      • From: "Stephen J. Butler" <email@hidden>
  • Prev by Date: UIWebView IBOutlet is always nil
  • Next by Date: Re: how to run NSApplicationMain() in child process?
  • Previous by thread: Re: UIWebView IBOutlet is always nil
  • Next by thread: Re: how to run NSApplicationMain() in child process?
  • Index(es):
    • Date
    • Thread