【问题标题】:App Store can not close my Qt applicationApp Store 无法关闭我的 Qt 应用程序
【发布时间】:2015-03-24 06:48:23
【问题描述】:

如果存在更新,App Store 无法关闭我的应用程序(我发送到那里)。

App Store 询问我“我可以关闭此应用程序吗?”。我说是”。它挂了几秒钟,然后再次问我“我可以关闭这个应用程序吗?”

我看到了 OSX 事件日志,但什么也没有

Qt 5.4
OSX 10.10.2

【问题讨论】:

    标签: macos qt app-store


    【解决方案1】:

    App Store 可能会发送一个SIGTERM 信号来通知您的进程关闭。因为你没有处理它,所以什么也没有发生。您需要实现一个 unix 信号处理程序,如 "Calling Qt Functions From Unix Signal Handlers" tutorial 所示。

    类似这样的未经测试混乱:

    int setup_unix_signal_handlers()
    {
        struct sigaction term;
    
        term.sa_handler = ::termSignalHandler;
        sigemptyset(&term.sa_mask);
        term.sa_flags |= SA_RESTART;
    
        return sigaction(SIGTERM, &term, 0);
    }
    
    void termSignalHandler(int)
    {
        QCoreApplication::exit(0);
    }
    
    int main(int argc, char *argv[])
    {
        setup_unix_signal_handlers();
        QCoreApplication a(argc, argv);
        return a.exec();
    }
    

    信号处理综合讲解:Simple Linux Signal Handling

    【讨论】:

    • 我这样做了,但是当我输入命令“kill -SIGTERM PID”时 termSignalHandler 没有调用
    猜你喜欢
    • 1970-01-01
    • 2011-05-19
    • 1970-01-01
    • 1970-01-01
    • 2014-11-23
    • 1970-01-01
    • 2011-02-04
    • 1970-01-01
    • 2021-07-09
    相关资源
    最近更新 更多