Re: [linux-audio-dev] Daemon mode

From: Lars Luthman <lars.luthman@email-addr-hidden>
Date: Sat Dec 16 2006 - 13:17:46 EET

On Sat, 2006-12-16 at 12:14 +0100, Lars Luthman wrote:
> On Sat, 2006-12-16 at 17:56 +0700, Patrick Shirkey wrote:
> > Hi,
> >
> > I am adding a Daemon mode to jackEQ and have most of the code in place now.
> >
> > I am stuck at the point where the daemon starts up and keeps going.
> >
> > Essentially I need the daemon mode equivalent of gtk_main() that keeps
> > ticking over until the app is told to stop or otherwise shutdown.
> >
> > I have not threaded the app at this point so hopefully there is a very
> > simple solution.
>
> So the only thread that needs to do anything is the JACK thread? In that
> case you can just add something like
>
> ... init code ...
>
> bool run = true;
> while (run) sleep(10000);
>
> ... cleanup code ...
>
> in the main thread, after setting up JACK. If you want to be nice you
> can add signal handlers for SIGHUP and SIGINT that set 'run' to false.

Ehm, and in that case you better change the sleep time to 1 or use
usleep() and specify microseconds instead. You wouldn't want to wait for
hours after trying to stop the program.

Or is sleep() interrupted by signals even if there are signal handlers
for them?

-- 
Lars Luthman - please encrypt any email sent to me if possible
PGP key: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x04C77E2E
Fingerprint: FCA7 C790 19B9 322D EB7A E1B3 4371 4650 04C7 7E2E

Received on Sat Dec 16 16:15:03 2006

This archive was generated by hypermail 2.1.8 : Sat Dec 16 2006 - 16:15:03 EET