PtyProcess.h
/*
* $Id: PtyProcess.h 3362 2012-08-08 14:41:11Z karijes $
*
* This class enables to "chat" with terminal programs synchronously
* Copyright (c) 2006-2009 edelib authors
*
* This file was a part of the KDE project, module kdesu.
* Copyright (C) 1999,2000 Geert Jansen <jansen@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __EDELIB_PTYPROCESS_H__
#define __EDELIB_PTYPROCESS_H__
#include "edelib-global.h"
#include <sys/types.h>
EDELIB_NS_BEGIN
class PTY;
class EDELIB_API PtyProcess {
private:
int init();
int setup_tty(int fd);
PTY *m_pPTY;
char *m_Inbuf, *m_TTY;
class PtyProcessPrivate;
PtyProcessPrivate *d;
E_DISABLE_CLASS_COPY(PtyProcess)
protected:
#ifndef SKIP_DOCS
char **environment() const;
bool m_bErase, m_bTerminal;
int m_Pid, m_Fd;
char *m_Command, *m_Exit;
#endif
public:
PtyProcess();
virtual ~PtyProcess();
int exec(const char *command, const char **args);
char *read_line(bool block=true);
void write_line(const char *line, bool addNewline=true);
void unread_line(const char *line, bool addNewline=true);
void set_exit_string(char *exit) { m_Exit = exit; }
int wait_for_child();
int wait_slave();
int enable_local_echo(bool enable=true);
void set_terminal(bool terminal) { m_bTerminal = terminal; }
void set_erase(bool erase) { m_bErase = erase; }
void set_environment( const char **env );
inline int fd() const { return m_Fd; }
inline int pid() const { return m_Pid; }
void terminate_child();
static int wait_ms(int fd,int ms);
static bool check_pid(pid_t pid);
enum CheckPidStatus { Error=-1, NotExited=-2, Killed=-3, Crashed=-4 } ;
static int check_pid_exited(pid_t pid);
};
EDELIB_NS_END
#endif
edelib::PTY
emulate pty api
Definition: Pty.h:38
edelib::PtyProcess::CheckPidStatus
CheckPidStatus
Definition: PtyProcess.h:182
edelib::PtyProcess::set_exit_string
void set_exit_string(char *exit)
Definition: PtyProcess.h:109
edelib::PtyProcess::set_terminal
void set_terminal(bool terminal)
Definition: PtyProcess.h:131
edelib::PtyProcess::fd
int fd() const
Definition: PtyProcess.h:147
E_DISABLE_CLASS_COPY
#define E_DISABLE_CLASS_COPY(klass)
Definition: edelib-global.h:161
edelib::PtyProcess::pid
int pid() const
Definition: PtyProcess.h:152
edelib::PtyProcess::set_erase
void set_erase(bool erase)
Definition: PtyProcess.h:137
edelib::PtyProcess
Synchronous communication with tty programs.
Definition: PtyProcess.h:42