HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- USING PSEUDO TERMINALS
Operating System - HP-UX
1825756
Members
2332
Online
109687
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2008 04:11 AM
12-02-2008 04:11 AM
USING PSEUDO TERMINALS
Hi All,
I have a small requirement in one of our projects to read and write from pseudo terminals.
for this i have written 2 programs
1) master.cpp
2) slave.cpp
First master opens a pseudo terminal using the function openpty();
and uses select call to wait until data appears on the slave.
Once we run slave program and enter something into the slave device, the same thing is read from master.
And the master has to send some text to the slave.
I am able to write into slave and read from master.
But, after reading in master i am not able to write back to slave.
I am attaching both my master.cpp and my slave.cpp is as below.
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
#define SIZE 25
int main ()
{
char buffer[205];
int slavept;
slavept=open("/dev/pts/6", O_RDWR|O_NOCTTY ); // Use the slave device opened by master.cpp
fd_set readfd, errfd;
int selret;
struct timeval time;
//grantpt( slavept ) ;
//unlockpt( slavept );
time.tv_sec = 2;
while (1)
{
//cout <<"ENTER WIZARD COMMAND ==>"<< endl;
//cin >> buffer;
int num=write(slavept,buffer,SIZE);
//sleep(20);
FD_ZERO(&readfd);
FD_SET(slavept, &readfd);
//sleep (10);
selret = select(slavept+1, &readfd, NULL, NULL, NULL);
cout << "SelRet =" << selret << endl;
//
if (selret > 0 )
{
read( slavept, buffer, SIZE );
cout << "DATA FROM MASTER IS =>"< }
}
close( slavept );
return 0;
}
Can any one have a look at it and please help me out to get rid of this blockage
Thanks in Advance
Vikram
I have a small requirement in one of our projects to read and write from pseudo terminals.
for this i have written 2 programs
1) master.cpp
2) slave.cpp
First master opens a pseudo terminal using the function openpty();
and uses select call to wait until data appears on the slave.
Once we run slave program and enter something into the slave device, the same thing is read from master.
And the master has to send some text to the slave.
I am able to write into slave and read from master.
But, after reading in master i am not able to write back to slave.
I am attaching both my master.cpp and my slave.cpp is as below.
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
#define SIZE 25
int main ()
{
char buffer[205];
int slavept;
slavept=open("/dev/pts/6", O_RDWR|O_NOCTTY ); // Use the slave device opened by master.cpp
fd_set readfd, errfd;
int selret;
struct timeval time;
//grantpt( slavept ) ;
//unlockpt( slavept );
time.tv_sec = 2;
while (1)
{
//cout <<"ENTER WIZARD COMMAND ==>"<< endl;
//cin >> buffer;
int num=write(slavept,buffer,SIZE);
//sleep(20);
FD_ZERO(&readfd);
FD_SET(slavept, &readfd);
//sleep (10);
selret = select(slavept+1, &readfd, NULL, NULL, NULL);
cout << "SelRet =" << selret << endl;
//
if (selret > 0 )
{
read( slavept, buffer, SIZE );
cout << "DATA FROM MASTER IS =>"<
}
close( slavept );
return 0;
}
Can any one have a look at it and please help me out to get rid of this blockage
Thanks in Advance
Vikram
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Support
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP