mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-10-14 03:30:59 -07:00
Leave SIGPIPE disposition unchanged so Python can handle a disconnected output pipe as EPIPE instead of terminating the editor. Add a native regression test that verifies the ignored disposition and a write to a closed pipe. Validation: 50 CrashHandler, Logger, and Timeline tests passed. A Python subprocess exits with signal 13 using the installed library and survives the same closed-pipe write using the rebuilt library.
33 lines
1.0 KiB
C++
33 lines
1.0 KiB
C++
// Copyright (c) 2026 OpenShot Studios, LLC
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
#include "openshot_catch.h"
|
|
#include "CrashHandler.h"
|
|
|
|
#ifndef _WIN32
|
|
#include <cerrno>
|
|
#include <csignal>
|
|
#include <unistd.h>
|
|
|
|
TEST_CASE("Crash handler preserves ignored SIGPIPE", "[crash-handler]") {
|
|
// Python ignores SIGPIPE so a disconnected console raises EPIPE instead
|
|
// of terminating the editor. Native initialization must preserve that.
|
|
struct sigaction ignored = {};
|
|
ignored.sa_handler = SIG_IGN;
|
|
sigemptyset(&ignored.sa_mask);
|
|
REQUIRE(sigaction(SIGPIPE, &ignored, nullptr) == 0);
|
|
openshot::CrashHandler::Instance();
|
|
struct sigaction current = {};
|
|
REQUIRE(sigaction(SIGPIPE, nullptr, ¤t) == 0);
|
|
REQUIRE(current.sa_handler == SIG_IGN);
|
|
|
|
int pipe_fds[2];
|
|
REQUIRE(pipe(pipe_fds) == 0);
|
|
close(pipe_fds[0]);
|
|
const auto result = write(pipe_fds[1], "x", 1);
|
|
const auto error = errno;
|
|
close(pipe_fds[1]);
|
|
CHECK(result == -1);
|
|
CHECK(error == EPIPE);
|
|
}
|
|
#endif
|