From 976ae0f75abd019312c7072a97e39f28c7db3f71 Mon Sep 17 00:00:00 2001 From: flightlessmango Date: Tue, 9 Apr 2024 01:48:45 +0200 Subject: [PATCH] shell: fix more unused warnings --- src/shell.cpp | 8 +++++++- src/shell.h | 5 +---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/shell.cpp b/src/shell.cpp index 83d7c529..64d6acb8 100644 --- a/src/shell.cpp +++ b/src/shell.cpp @@ -84,8 +84,14 @@ std::string Shell::exec(std::string cmd) { return readOutput(); } +void Shell::writeCommand(const std::string& command) { + if (write(to_shell[1], command.c_str(), command.length()) == -1) + SPDLOG_ERROR("Failed exit shell"); +} + Shell::~Shell() { - write(to_shell[1], "exit\n", 5); + if (write(to_shell[1], "exit\n", 5) == -1) + SPDLOG_ERROR("Failed exit shell"); close(to_shell[1]); close(from_shell[0]); waitpid(shell_pid, nullptr, 0); diff --git a/src/shell.h b/src/shell.h index 1154a3f3..db762683 100644 --- a/src/shell.h +++ b/src/shell.h @@ -22,10 +22,7 @@ private: } #endif - void writeCommand(const std::string& command) { - write(to_shell[1], command.c_str(), command.length()); - } - + void writeCommand(const std::string& command); std::string readOutput(); public: