summaryrefslogtreecommitdiff
path: root/test/v4l2_videodevice/buffer_sharing.cpp
diff options
context:
space:
mode:
authorYou-Sheng Yang <vicamo.yang@canonical.com>2020-07-25 20:24:40 +0800
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-07-27 13:53:53 +0300
commit774f0d1b9b59f5a779d0bf257b365f307cf191f8 (patch)
tree9a189754702b2d029e1f8be90c292ed53d188aa9 /test/v4l2_videodevice/buffer_sharing.cpp
parent256845d5b7edf97b77a99257d18e53d3453bc534 (diff)
libcamera: process: Fix killing innocent processes unexpectedly
When a libcamera::process is being destructed or called kill() without a previous successful call to start(), it's pid_ may remains -1, which causes all the killable processes being killed when passed to `kill(pid_, SIG_KILL)`. Signed-off-by: You-Sheng Yang <vicamo.yang@canonical.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'test/v4l2_videodevice/buffer_sharing.cpp')
0 files changed, 0 insertions, 0 deletions
pan> "test.h" using namespace std; using namespace libcamera; class EventTest : public Test { protected: void readReady(EventNotifier *notifier) { size_ = read(notifier->fd(), data_, sizeof(data_)); notified_ = true; } int init() { return pipe(pipefd_); } int run() { EventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher(); std::string data("H2G2"); Timer timeout; EventNotifier readNotifier(pipefd_[0], EventNotifier::Read); readNotifier.activated.connect(this, &EventTest::readReady); /* Test read notification with data. */ memset(data_, 0, sizeof(data_)); size_ = 0; write(pipefd_[1], data.data(), data.size()); timeout.start(100); dispatcher->processEvents(); timeout.stop(); if (static_cast<size_t>(size_) != data.size()) { cout << "Event notifier read ready test failed" << endl; return TestFail; } /* Test read notification without data. */ notified_ = false; timeout.start(100); dispatcher->processEvents(); timeout.stop(); if (notified_) { cout << "Event notifier read no ready test failed" << endl; return TestFail; } /* Test read notifier disabling. */ notified_ = false; readNotifier.setEnabled(false); write(pipefd_[1], data.data(), data.size()); timeout.start(100); dispatcher->processEvents(); timeout.stop(); if (notified_) { cout << "Event notifier read disabling failed" << endl; return TestFail; } /* Test read notifier enabling. */ notified_ = false; readNotifier.setEnabled(true); timeout.start(100); dispatcher->processEvents(); timeout.stop(); if (!notified_) { cout << "Event notifier read enabling test failed" << endl; return TestFail; } return TestPass; } void cleanup() { close(pipefd_[0]); close(pipefd_[1]); } private: int pipefd_[2]; bool notified_; char data_[16]; ssize_t size_; }; TEST_REGISTER(EventTest)