Ejemplo n.º 1
0
int main() {
    Daemon d;
    if(d.isUnique()) {
        daemon(0, 0);
        d.run();
    }
    return 0;
}
Ejemplo n.º 2
0
 void *daemon_launch_thread_(void *arg) {
     Daemon *d = (Daemon *)arg;
     dprintf(DBG_MINOR, "Dummy::Sensor: Launching dummy simulator thread\n");
     d->running = true;
     d->run();
     d->running = false;
     pthread_exit(NULL);
     return NULL;
 }
Ejemplo n.º 3
0
void* Daemon::entry(void* data){
	struct sync* td = (struct sync*)data;
	Daemon* daemon = td->daemon;

	/* setup self-pipe */
	if ( pipe2(daemon->pipe, O_NONBLOCK) != 0 ){
		int saved = errno;
		Log::fatal("main", "pipe2() returned %d: %s\n", saved, strerror(saved));
		td->value = saved;
		sem_post(&td->semaphore);
		return NULL;
	}

	td->value = daemon->init();
	sem_post(&td->semaphore);

	if ( td->value != 0 ){
		return NULL;
	}

	if ( td->barrier ){
		pthread_barrier_wait(td->barrier);
	}

	daemon->run();
	daemon->cleanup();

	/* close pipe */
	close(daemon->pipe[0]);
	close(daemon->pipe[1]);

	/* free resources */
	sem_destroy(&td->semaphore);
	free(td);

	return 0;
}
Ejemplo n.º 4
0
int main(int argc, char *argv[])
{
  Daemon *app = new Daemon(argc, argv);
  return app->run();
}