在嵌入式Linux系统上运行SDL应用程序作为守护进程

时间:2022-08-17 12:32:53

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.

我正在使用/ dev / fb0 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();

1 个解决方案

#1


0  

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

通过在切换到作为守护程序运行之前初始化SDL来解决。

#1


0  

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

通过在切换到作为守护程序运行之前初始化SDL来解决。