Daemon Processes

5 messages Options
Embed this post
Permalink
Marcus_wood

Daemon Processes

Reply Threaded More More options
Print post
Permalink
Hi there,

I am developing a plugin for mac os x that needs a 'daemon' style process in the background that can access the FM API
It would wait for notifications broadcast from another application (an NSNotification) and act on them by updating a table

If I fork() then it forks the whole FM process and if I start a separate executable then it wont be able to access the FM API

Has anyone had any experience with anything like this or could point me in the right direction?

Thanks :)
Marcus
Hayden Stainsby

Re: Daemon Processes

Reply Threaded More More options
Print post
Permalink
Firstly the disclaimer, this advice comes with no understanding of the  
FM API, but rather general OS X programming (well, Cocoa  
specifically). It would probably be worth trying to find out if the FM  
API is thread safe or not, someone else on this list might be able to  
comment on that.

If you're using NSNotification I'm guessing you're writing the daemon  
using objective-c and Cocoa, so I'd suggest you look at creating  
another thread (using NSThread) and do your processing in there.  
Assuming you're not going to be receiving these notifications with a  
high frequency (e.g. consistently high numbers per second) the cost of  
creating and tearing down an NSThread instance for each NSNotification  
you receive shouldn't be too high. If not creating a pool of worker  
threads would be more efficient (but a lot more work as well).

Hope this helps.

--
Hayden

On Oct 26, 2009, at 11:32 , Marcus Wood wrote:

>
> Hi there,
>
> I am developing a plugin for mac os x that needs a 'daemon' style  
> process in
> the background that can access the FM API
> It would wait for notifications broadcast from another application (an
> NSNotification) and act on them by updating a table
>
> If I fork() then it forks the whole FM process and if I start a  
> separate
> executable then it wont be able to access the FM API
>
> Has anyone had any experience with anything like this or could point  
> me in
> the right direction?
>
> Thanks :)
> Marcus
> --
> View this message in context: http://www.nabble.com/Daemon-Processes-tp26050389p26050389.html
> Sent from the Filemaker plug-in - Dev mailing list archive at  
> Nabble.com.
>
>
>


#!/usr/bin/perl
chop($_=<>);@s=split/ /;foreach$m(@s){if($m=='*'){$z=pop@t;$x=
pop@t;$a=eval"$x$m$z";push@t,$a;}else{push@t,$m;}}print"$a\n";
# http://voo-du.net/



------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/fmplug-prog-list/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/fmplug-prog-list/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[hidden email]
    mailto:[hidden email]

<*> To unsubscribe from this group, send an email to:
    [hidden email]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

Jake Traynham

Re: Daemon Processes

Reply Threaded More More options
Print post
Permalink
In reply to this post by Marcus_wood
Hi Marcus,

   I'm a little confused.  A plug-in is essentially a 'daemon' style
process already.  As soon as FileMaker Pro starts up your plug-in, it
remains in memory until FileMaker Pro is shut down (or if it's
auto-updated, it's shut down and restarted).  So, I'm thinking this
isn't the real question you are trying to ask.  Perhaps you've tried
something and it's not working as you expected?  Maybe if you explain a
little more about what you are trying to do and what you've done that
doesn't work, we can better help you.

Thanks,
Jake

Marcus Wood wrote:

>  
>
>
> Hi there,
>
> I am developing a plugin for mac os x that needs a 'daemon' style process in
> the background that can access the FM API
> It would wait for notifications broadcast from another application (an
> NSNotification) and act on them by updating a table
>
> If I fork() then it forks the whole FM process and if I start a separate
> executable then it wont be able to access the FM API
>
> Has anyone had any experience with anything like this or could point me in
> the right direction?
>
> Thanks :)
> Marcus
> --
> View this message in context:
> http://www.nabble.com/Daemon-Processes-tp26050389p26050389.html 
> <http://www.nabble.com/Daemon-Processes-tp26050389p26050389.html>
> Sent from the Filemaker plug-in - Dev mailing list archive at Nabble.com.
>
>

--
Jake Traynham
Owner, CNS Plug-ins
http://www.cnsplug-ins.com/
Marcus_wood

Re: Daemon Processes

Reply Threaded More More options
Print post
Permalink
Hi,

Ahh ok that explains a lot, I assumed FM launched the plugin as a separate executable
I have signed up for notifications in Startup() and it calls my callback great :)

I realize this is off topic a bit but..
I am new to C++ (but not to C) and so I have little understanding of the API.
In the header files it seems to declare all the different classes, but what I cant understand is how you can interact with the tables, I was going to ExecuteSQL() but it says its still "Experimental" so I assume theres another, preferred way?

Thanks for everyones help,
Marcus



Jake Traynham wrote:
Hi Marcus,

   I'm a little confused.  A plug-in is essentially a 'daemon' style
process already.  As soon as FileMaker Pro starts up your plug-in, it
remains in memory until FileMaker Pro is shut down (or if it's
auto-updated, it's shut down and restarted).  So, I'm thinking this
isn't the real question you are trying to ask.  Perhaps you've tried
something and it's not working as you expected?  Maybe if you explain a
little more about what you are trying to do and what you've done that
doesn't work, we can better help you.

Thanks,
Jake

Marcus Wood wrote:
>  
>
>
> Hi there,
>
> I am developing a plugin for mac os x that needs a 'daemon' style process in
> the background that can access the FM API
> It would wait for notifications broadcast from another application (an
> NSNotification) and act on them by updating a table
>
> If I fork() then it forks the whole FM process and if I start a separate
> executable then it wont be able to access the FM API
>
> Has anyone had any experience with anything like this or could point me in
> the right direction?
>
> Thanks :)
> Marcus
> --
> View this message in context:
> http://www.nabble.com/Daemon-Processes-tp26050389p26050389.html 
> <http://www.nabble.com/Daemon-Processes-tp26050389p26050389.html>
> Sent from the Filemaker plug-in - Dev mailing list archive at Nabble.com.
>
>

--
Jake Traynham
Owner, CNS Plug-ins
http://www.cnsplug-ins.com/
Jake Traynham

Re: Daemon Processes

Reply Threaded More More options
Print post
Permalink
Hello again,

Marcus Wood wrote:
>
> I realize this is off topic a bit but..
> I am new to C++ (but not to C) and so I have little understanding of the
> API.
> In the header files it seems to declare all the different classes, but what
> I cant understand is how you can interact with the tables, I was going to
> ExecuteSQL() but it says its still "Experimental" so I assume theres
> another, preferred way?
>

There is no other way.  The ExecuteSQL function is how you interact with
the tables.  It is labeled "Experimental", but I can assure you that
it's not going away.  There are a lot of plug-ins out now that use it.

Jake

--
Jake Traynham
Owner, CNS Plug-ins
http://www.cnsplug-ins.com/