Loading...
Searching...
No Matches
Pipe.h
Go to the documentation of this file.
// -*- c++ -*-
//------------------------------------------------------------------------------
// $Id: Pipe.h,v 1.3 2005/10/08 02:42:00 vlg Exp $
//------------------------------------------------------------------------------
// Pipe.h
//------------------------------------------------------------------------------
// Copyright (C) 1997-2002 Vladislav Grinchenko
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//------------------------------------------------------------------------------
#ifndef PIPE_H
#define PIPE_H
#include <stdio.h>
#include <string>
#include "assa/Logger.h"
namespace ASSA {
class Pipe
{
public:
Pipe ();
~Pipe ();
FILE* open (const string& cmd_, const string& type_);
int close ();
int kill ();
pid_t pid () const;
FILE* fp () const;
int fd () const;
private:
Pipe (const Pipe&);
Pipe& operator= (const Pipe&);
private:
FILE* m_fp;
pid_t m_child_pid;
};
inline pid_t
Pipe::pid () const { return m_child_pid; }
inline int
Pipe::fd () const { return fileno (m_fp); }
inline FILE*
Pipe::fp () const { return m_fp; }
} // end namespace ASSA
#endif // PIPE_H
Logger.h
An abstraction to message logging facility.
ASSA::AutoPtrRef
A wrapper class to provide AutoPtr with reference semantics.
Definition AutoPtr.h:32
ASSA::Pipe
Definition Pipe.h:29
ASSA::Pipe::m_child_pid
pid_t m_child_pid
Supbrocess' PID.
Definition Pipe.h:98
ASSA::Pipe::pid
pid_t pid() const
Get subprocess' PID.
Definition Pipe.h:102
ASSA::Pipe::fd
int fd() const
Get pipe's file descriptor.
Definition Pipe.h:105
ASSA::Pipe::fp
FILE * fp() const
Get pipe's standard I/O file pointer.
Definition Pipe.h:108
ASSA::Pipe::Pipe
Pipe()
A no-op constructor.
Definition Pipe.cpp:34
ASSA::Pipe::open
FILE * open(const string &cmd_, const string &type_)
Starts a subshell and feed it the string cmd_ to be executed.
Definition Pipe.cpp:51
ASSA::Pipe::m_fp
FILE * m_fp
A standard I/O stream descriptor.
Definition Pipe.h:93
ASSA::Pipe::kill
int kill()
Kill subprocess with SIGTERM.
Definition Pipe.cpp:118
ASSA::Pipe::Pipe
Pipe(const Pipe &)
ASSA::Pipe::operator=
Pipe & operator=(const Pipe &)
ASSA::Pipe::~Pipe
~Pipe()
Destructor calls close () first in an attempt to close opened pipe.
Definition Pipe.cpp:43
ASSA::Pipe::close
int close()
Close the pipe.
Definition Pipe.cpp:136
ASSA
Definition Acceptor.h:40