Redirect restart command to null

This commit is contained in:
Rico Tiongson 2020-04-18 02:54:14 +08:00
parent 68fce3819f
commit 94858c63fe
2 changed files with 9 additions and 2 deletions

View File

@ -19,6 +19,10 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <unistd.h> // popen, pclose
#include <memory> // std::unique_ptr
#include <cstdlib> // std::system
#include "../all_headers.hpp"
namespace comfortable_swipe::service
@ -28,7 +32,10 @@ namespace comfortable_swipe::service
*/
void restart()
{
comfortable_swipe::service::stop();
// stop, while redirecting stdout to pipe
std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(__COMFORTABLE_SWIPE__PROGRAM__ " stop", "r"), pclose);
// restart service
comfortable_swipe::service::start();
}
}

View File

@ -68,7 +68,7 @@ namespace comfortable_swipe::service
}
else
{
std::puts("No program to stop");
std::printf("No program to stop\n");
}
}
}