From 5c8e29731904aaf993df31dd7e97b1bbdadf07b3 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Wed, 5 Jun 2019 18:58:56 +0200 Subject: [PATCH] popen: add getter for pid --- common/include/villas/popen.hpp | 11 ++++++++--- common/tests/unit/popen.cpp | 6 +++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/common/include/villas/popen.hpp b/common/include/villas/popen.hpp index 5f72489b6..ba1c8ba63 100644 --- a/common/include/villas/popen.hpp +++ b/common/include/villas/popen.hpp @@ -48,21 +48,26 @@ public: int close(); void kill(int signal = SIGINT); - std::istream &in() + std::istream &cin() { return *(input.stream); } - std::ostream &out() + std::ostream &cout() { return *(output.stream); } - int fd() + int getFd() { return input.buffer->fd(); } + pid_t getPid() const + { + return pid; + } + protected: std::string command; pid_t pid; diff --git a/common/tests/unit/popen.cpp b/common/tests/unit/popen.cpp index d3ef7d30e..22d41c85b 100644 --- a/common/tests/unit/popen.cpp +++ b/common/tests/unit/popen.cpp @@ -33,12 +33,12 @@ Test(popen, cat) { Popen proc("cat"); - proc.out() << "Hello World" << std::endl; - proc.out().flush(); + proc.cout() << "Hello World" << std::endl; + proc.cout().flush(); std::string str, str2; - proc.in() >> str >> str2; + proc.cin() >> str >> str2; cr_assert_eq(str, "Hello"); cr_assert_eq(str2, "World");