1

I'm developing an application using /dev/fb0 framebuffer for graphics output. Running fine when executed from the terminal but when I try to run it as a daemon it won't output anything on the framebuffer.

    pid_t pid, sid;

    pid = fork();
    if (pid < 0) {
        exit(EXIT_FAILURE);
    }

    if (pid > 0) {
        exit(EXIT_SUCCESS);
    }

    umask(0);

    setlogmask (LOG_UPTO (LOG_NOTICE));
    openlog ("nattisserver", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);     
    syslog (LOG_NOTICE, "nattisserver daemon starting..", getuid ());

    sid = setsid();
    if (sid < 0) {
        exit(EXIT_FAILURE);
    }

    if ((chdir("/root/")) < 0) {
        exit(EXIT_FAILURE);
    }

    close(STDIN_FILENO);
    close(STDOUT_FILENO);
    close(STDERR_FILENO);

    // My routines for drawing content to the framebuffer
    get_ibus_departures();

    nattis_sdl_init();

    nattis_sdl_draw();
genpfault
  • 51,148
  • 11
  • 85
  • 139

1 Answers1

1

Solved by initializing SDL before switching to running as a daemon.