从程序派生时的boost dataflow_exception
boost dataflow_exception when forked from program
我最近移植了一个Qt应用程序,使用QTcpSockets而不是直接使用posix。我使用的渲染器有代码,如果视图应用程序还没有运行,可以通过分叉来启动它。对于我新重构的应用程序,如果在运行渲染器之前启动该应用程序,它似乎可以正常工作。然而,如果我在视图应用程序尚未运行的情况下启动渲染器,它将调用fork代码,程序通常会在渲染的中途崩溃。
Qt has caught an exception thrown from an event handler. Throwing
exceptions from an event handler is not supported in Qt. You must
reimplement QApplication::notify() and catch all exceptions there.
terminate called after throwing an instance of '
boost::archive::iterators::dataflow_exception'
what(): attempt to decode a value not in base64 char set
由于只有在使用fork()方法时才会抛出此异常,我想知道这是否是重构中的问题?我也相信只有当Qt应用程序从内部运行渲染器(启动查看器应用程序)时才会发生这种情况。当视图应用程序直接从渲染器分叉时,我看不到这个问题。我不确定fork()可能在做什么,从而导致这个异常。
int pid = fork();
if (pid != -1)
{
if (!pid)
{
// Child process executes the following after forking.
char arg1[] = "piqsl";
char arg2[] = "-i";
char arg3[] = "127.0.0.1";
char* argv[4] = {arg1, arg2, arg3, NULL};
// TODO: need to pass verbosity level for logginng
signal(SIGHUP, SIG_IGN);
nice(2);
execvp("piqsl",argv);
...
重构后的查看器应用程序的唯一区别是它使用了QTcpSockets(和QTcpServer),现在链接到libQNetwork。这个库现在可能会对boost造成干扰吗?
问题是fork()创建了原始进程的精确副本,包括所有打开的文件句柄。Qt似乎使用了一些管道/套接字进行内部通信,由于这些管道/套接字与分叉进程中的管道/套接字相同,因此它们与原始进程冲突。
您可能会更幸运地使用exec()——据我所知,在分叉后没有办法安全地重新实例化QApplication。或者,如果您在创建QApplication之前分叉,它应该可以工作。
相关文章:
- 为重写std::exception的库生成swig接口时出错
- 什么是 std::exception::what() 以及为什么要使用它?
- 链表"exception thrown"
- 为什么程序员同时使用 std::bad_alloc 和 std::exception.是否 std::例外 仅是不够的
- C++ broken_promise exception
- 请参阅在 Visual Studio 2019 中捕获 std::exception 时对函数模板实例化消息的引用
- QVTKWidget SetRenderWindow() with PCLVisualizer Exception
- 自定义派生的 std::exception 类的 'what' 函数返回神秘的废话
- 使用flag、return、exception、goto或break中止过程
- 由于某种原因,我的代码中出现了 [json.exception.type_error.302]。我知道错误意味着什么,但我不知道哪里有故障
- 派生自 std::exception 的类的赋值运算符
- 尝试打印字符串时"Python Exception <class 'gdb.error'> There is no member named _M_dataplus."
- std::exception :使用虚函数和继承与变量
- MFC ODBC SQLConfigDataSource() Unhandled Exception
- 这段 C++ 代码的奇怪行为(std::wcout 和 std::exception)
- VTK 7.1.1: vtkX3DExporter exception
- 无法在"catch(const std::exception &ex)"中捕获 std::invalid_argument
- opencv cv::addText exception if no window
- Ctypes: OSError: exception: stack overflow
- C++ CMake 构建错误:未定义对"boost::throw_exception(std::exception const&)"的引用