Lars Luthman wrote:
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?
Thanks for the pointer Lars.
However I'm using c so this code doesn't work. I have modified it like so:
int run = TRUE;
while (run)
sleep(10000);
but that just gives a segv. It runs for about a second then gives up.
I'm also looking at the code for jackd and have spotted this function:
sigwait (&signals, &sig);
so I added some new bits and pieces like so:
static sigset_t signals;
int main(int argc, char *argv[])
{
int run;
int sig;
sigset_t allsignals;
sigemptyset (&signals);
sigaddset(&signals, SIGHUP);
sigaddset(&signals, SIGINT);
sigaddset(&signals, SIGQUIT);
sigaddset(&signals, SIGPIPE);
sigaddset(&signals, SIGTERM);
sigfillset (&allsignals);
process_init();
run = TRUE;
while (run)
sigwait (&signals, &sig);
return 0;
}
but that also returns segv at sigwait(). If I put a printf after sigwait
it doesn't print. Before is ok.
I'm not sure how to proceed from here.
Cheers.
--
Patrick Shirkey - Boost Hardware Ltd.
Http://www.boosthardware.com
Http://lau.linuxaudio.org - The Linux Audio Users guide
========================================
"Anything your mind can see you can manifest physically, then it will
become reality" - Macka B