]> git.sesse.net Git - cubemap/blobdiff - httpinput.h
Stop leaking the /dev/null fd after spawning a subprocess.
[cubemap] / httpinput.h
index 4ee5ede87542866182133f23b40b2bb12b8735c7..1ee1f8f5c4d134e3066ec65f6923b74effc2489a 100644 (file)
@@ -2,6 +2,7 @@
 #define _HTTPINPUT_H 1
 
 #include <stddef.h>
+#include <sys/types.h>
 #include <mutex>
 #include <string>
 #include <vector>
@@ -12,6 +13,8 @@
 
 class InputProto;
 
+// Despite the name, covers input over both HTTP and pipes, both typically
+// wrapped in Metacube.
 class HTTPInput : public Input {
 public:
        HTTPInput(const std::string &url, Input::Encoding encoding);
@@ -35,6 +38,10 @@ private:
        // Open a socket that connects to the given host and port. Does DNS resolving.
        int lookup_and_connect(const std::string &host, const std::string &port);
 
+       // Open a child process with the given command line (given to /bin/sh).
+       // Returns a pipe to its standard output.
+       int open_child_process(const std::string &cmdline);
+
        // Parses a HTTP response. Returns false if it not a 200.
        bool parse_response(const std::string &response);
 
@@ -93,6 +100,9 @@ private:
        // The socket we are downloading on (or -1).
        int sock = -1;
 
+       // pid of the cihld process (or -1).
+       pid_t child_pid = -1;
+
        // Mutex protecting <stats>.
        mutable std::mutex stats_mutex;