libassa 3.5.1
Loading...
Searching...
No Matches
Pipe.h
Go to the documentation of this file.
1// -*- c++ -*-
2//------------------------------------------------------------------------------
3// $Id: Pipe.h,v 1.3 2005/10/08 02:42:00 vlg Exp $
4//------------------------------------------------------------------------------
5// Pipe.h
6//------------------------------------------------------------------------------
7// Copyright (C) 1997-2002 Vladislav Grinchenko
8//
9// This library is free software; you can redistribute it and/or
10// modify it under the terms of the GNU Library General Public
11// License as published by the Free Software Foundation; either
12// version 2 of the License, or (at your option) any later version.
13//------------------------------------------------------------------------------
14#ifndef PIPE_H
15#define PIPE_H
16
17#include <stdio.h>
18#include <string>
19
20#include "assa/Logger.h"
21
22namespace ASSA {
23
28class Pipe
29{
30public:
34 Pipe ();
35
39 ~Pipe ();
40
56 FILE* open (const string& cmd_, const string& type_);
57
65 int close ();
66
74 int kill ();
75
77 pid_t pid () const;
78
80 FILE* fp () const;
81
83 int fd () const;
84
85private:
86 Pipe (const Pipe&);
88
89private:
94
99};
100
101inline pid_t
102Pipe::pid () const { return m_child_pid; }
103
104inline int
105Pipe::fd () const { return fileno (m_fp); }
106
107inline FILE*
108Pipe::fp () const { return m_fp; }
109
110} // end namespace ASSA
111
112#endif // PIPE_H
113
An abstraction to message logging facility.
A wrapper class to provide AutoPtr with reference semantics.
Definition AutoPtr.h:32
pid_t m_child_pid
Supbrocess' PID.
Definition Pipe.h:98
pid_t pid() const
Get subprocess' PID.
Definition Pipe.h:102
int fd() const
Get pipe's file descriptor.
Definition Pipe.h:105
FILE * fp() const
Get pipe's standard I/O file pointer.
Definition Pipe.h:108
Pipe()
A no-op constructor.
Definition Pipe.cpp:34
FILE * open(const string &cmd_, const string &type_)
Starts a subshell and feed it the string cmd_ to be executed.
Definition Pipe.cpp:51
FILE * m_fp
A standard I/O stream descriptor.
Definition Pipe.h:93
int kill()
Kill subprocess with SIGTERM.
Definition Pipe.cpp:118
Pipe(const Pipe &)
Pipe & operator=(const Pipe &)
~Pipe()
Destructor calls close () first in an attempt to close opened pipe.
Definition Pipe.cpp:43
int close()
Close the pipe.
Definition Pipe.cpp:136