BabitMF / bmf

Cross-platform, customizable multimedia/video processing framework. With strong GPU acceleration, heterogeneous design, multi-language support, easy to use, multi-framework compatible and high performance, the framework is ideal for transcoding, AI inference, algorithm integration, live video streaming, and more.
https://babitmf.github.io/
Apache License 2.0
730 stars 60 forks source link

内部注册的 SIGTERM 和 SIGINT 信号处理器导致应用无法正常退出 #121

Open lichuangcheng opened 4 weeks ago

lichuangcheng commented 4 weeks ago

嗨,bmf 很好用 但我在 bmf/engine/c_engine/src/graph.cpp 中的 Graph::Graph 构造函数中发现:

Graph::Graph(
    GraphConfig graph_config,
    std::map<int, std::shared_ptr<Module>> pre_modules,
    std::map<int, std::shared_ptr<ModuleCallbackLayer>> callback_bindings) {
    std::signal(SIGTERM, terminate);
    std::signal(SIGINT, interrupted);
    ...
}

这里注册的这两个信号处理器总是导致我的应用无法正常退出,因为它接管了这两个信号的处理,就像下面这样:

^Cinterrupted, ending bmf gracefully...
^Cinterrupted, ending bmf gracefully...
^Cinterrupted, ending bmf gracefully...

但是作为 SDK / 依赖包,它不应该依赖信号处理来清理资源,而是应该使用 RAII 或其他方式。

或者,我是否有其他解决办法让我的应用在接收到 SIGTERMSIGINT 时能正常退出?

sfeiwong commented 2 weeks ago

Hi,“它不应该依赖信号处理来清理资源,而是应该使用 RAII 或其他方式”,是个好的建议。

sfeiwong commented 2 weeks ago

不知道遇到的问题解决了吗?