/usr/include/assa-3.5/assa/Pipe.h is in libassa-3.5-5-dev 3.5.1-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | // -*- 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 {
/** @file Pipe.h
* A wrapper around UNIX popen()/pclose() standard library calls.
*/
class Pipe
{
public:
/**
* A no-op constructor
*/
Pipe ();
/**
* Destructor calls close () first in an attempt to close opened pipe.
*/
~Pipe ();
/**
* Starts a subshell and feed it the string cmd_ to be executed.
* The pipe is created and attached to the standard input or standard
* output of the subprocess, according to whether type_ is either "r"
* (read) or "w" (write). The other end of the pipe is returned to the
* calling code as a standard I/O stream, FILE, ready for buffered use
* with fprintf(), fscanf(), fgets, etc.
*
* @see Fork
* @param cmd_ command to execute
* @param type_ "w" for write pipe and "r" for read pipe
* @return pointer to a standard I/O stream. In case of error,
* NULL is returned with errno set to indicate the type of error
* encountered.
*/
FILE* open (const string& cmd_, const string& type_);
/**
* Close the pipe. The subprocess' status is collected to ensure
* that the child process have finished.
*
* @return 0 on success; -1 on error.
*/
int close ();
/**
* Kill subprocess with SIGTERM. You should most probably call
* close() afterwards to collect child process' status.
*
* @see close()
* @return 0 on success, -1 if kill(2) failed.
*/
int kill ();
/** Get subprocess' PID. */
pid_t pid () const;
/** Get pipe's standard I/O file pointer */
FILE* fp () const;
/** Get pipe's file descriptor */
int fd () const;
private:
Pipe (const Pipe&);
Pipe& operator= (const Pipe&);
private:
/**
* A standard I/O stream descriptor
*/
FILE* m_fp;
/**
* Supbrocess' PID
*/
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
|