wvpty.h

00001 /* -*- Mode: C++ -*-
00002  * Worldvisions Weaver Software:
00003  *   Copyright (C) 1997-2004 Net Integration Technologies, Inc.
00004  * 
00005  * WvStreams implementation of ptys under Linux.
00006  *
00007  * For more information on programming ptys, see chapter 19 of
00008  * Stevens' "Advanced Programming in the UNIX Environment"
00009  */
00010 #ifndef __WVPTY_H
00011 #define __WVPTY_H
00012 
00013 #include "wvfdstream.h"
00014 #include "wvcallback.h"
00015 
00016 class WvPty : public WvFDStream
00017 {
00018     private:
00019 
00020         WvString _master, _slave;
00021         pid_t _pid;
00022         int _exit_status;
00023 
00024         static bool open_pty(WvString &master, int &master_fd,
00025                 WvString &slave, int &slave_fd);
00026 
00027         void monitor_child(bool wait);
00028         
00029     public:
00030     
00031         typedef WvCallback<bool, WvPty &> Callback;
00032 
00033         Callback pre_exec_cb;
00034         Callback post_exec_cb; // This can only be called if exec() fails
00035 
00036     public:
00037 
00038         WvPty(const char *program, const char * const *argv,
00039                 Callback _pre_exec_cb = Callback(),
00040                 Callback _post_exec_cb = Callback());
00041 
00042         void kill(int signum);
00043         bool child_exited();
00044         bool child_killed();
00045         int finish();
00046         int exit_status();
00047         
00048         const char *master() const
00049             { return _master; }
00050         const char *slave() const
00051             { return _slave; }
00052         pid_t pid() const
00053             { return _pid; }
00054             
00055     public:
00056         const char *wstype() const { return "WvPty"; }
00057 };
00058 
00059 #endif // __WVPTY_H

Generated on Fri Oct 5 18:20:28 2007 for WvStreams by  doxygen 1.5.3