GNU Octave  9.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
oct-procbuf.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1996-2024 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 // This class is based on the procbuf class from libg++, written by
27 // Per Bothner, Copyright (C) 1993 Free Software Foundation.
28 
29 #if ! defined (octave_oct_procbuf_h)
30 #define octave_oct_procbuf_h 1
31 
32 #include "octave-config.h"
33 
34 #include <sys/types.h>
35 
36 #include "c-file-ptr-stream.h"
37 
39 
40 class
41 procbuf : public c_file_ptr_buf
42 {
43 public:
44 
46  : c_file_ptr_buf (nullptr), m_wstatus (-1), m_open_p (false),
47  m_proc_pid (-1), m_next (nullptr)
48  { }
49 
50  procbuf (const char *command, int mode)
51  : c_file_ptr_buf (nullptr), m_wstatus (-1), m_open_p (false),
52  m_proc_pid (-1), m_next (nullptr)
53  { open (command, mode); }
54 
55  OCTAVE_DISABLE_COPY_MOVE (procbuf)
56 
57  ~procbuf () { close (); }
58 
59  procbuf * open (const char *command, int mode);
60 
61  procbuf * close ();
62 
63  int wait_status () const { return m_wstatus; }
64 
65  bool is_open () const { return m_open_p; }
66 
67  pid_t pid () const { return m_proc_pid; }
68 
69 protected:
70 
71  int m_wstatus;
72 
73  bool m_open_p;
74 
75  pid_t m_proc_pid;
76 
78 };
79 
80 OCTAVE_END_NAMESPACE(octave)
81 
82 #endif
~procbuf()
Definition: oct-procbuf.h:57
pid_t m_proc_pid
Definition: oct-procbuf.h:75
pid_t pid() const
Definition: oct-procbuf.h:67
bool is_open() const
Definition: oct-procbuf.h:65
int m_wstatus
Definition: oct-procbuf.h:71
procbuf * m_next
Definition: oct-procbuf.h:77
procbuf(const char *command, int mode)
Definition: oct-procbuf.h:50
bool m_open_p
Definition: oct-procbuf.h:73
int wait_status() const
Definition: oct-procbuf.h:63
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn