LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-07-2012, 02:53 PM   #1
rkyser
LQ Newbie
 
Registered: Apr 2012
Posts: 5

Rep: Reputation: Disabled
Does pppd lock slave pty devices?


First of all, let me say that I have little experience with pppd and pseudo-terminals. So, if you say to yourself, "Huh, what is this guy talking about," I probably didn't say it correctly :-)

The setup:
I have a bluetooth application which gets a master and slave pty device pair. Then an instance of pppd is spawned, and given the following arguments:

debug
nodetach
logfd 2
dump
name SOMENAME@SOMEDOMAIN.COM
/dev/pts/0
115200
receive-all
ipcp-accept-remote
noipdefault
defaultroute
usepeerdns
:1.1.1.1

Finally, I have a test application which I want to use to open /dev/pts/0 (the slave device). I can open the /dev/pts/0 device, but I cannot read or write to it. I get a "Resource Temporarily Unavailable" error. (I've also tried to directly echo into it)

The question:
Does pppd lock (or make unavailable somehow) a slave device node that it is using? I have looked through the source code, and saw some stuff about locking, but I thought I would draw on the community experience before reverse engineering pppd :-)

Thank you.
 
Old 08-08-2012, 08:46 AM   #2
colorpurple21859
LQ Veteran
 
Registered: Jan 2008
Location: florida panhandle
Distribution: Slackware Debian, Fedora, others
Posts: 7,346

Rep: Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589
igoore this, had a a few different tabs opened and somehow posted on the wrong one. lol

Last edited by colorpurple21859; 08-08-2012 at 08:47 AM.
 
Old 08-08-2012, 08:57 AM   #3
rkyser
LQ Newbie
 
Registered: Apr 2012
Posts: 5

Original Poster
Rep: Reputation: Disabled
Doh! And I got all excited when I got an email about a reply!
 
Old 08-08-2012, 10:05 AM   #4
rkyser
LQ Newbie
 
Registered: Apr 2012
Posts: 5

Original Poster
Rep: Reputation: Disabled
The slave node that I was attempting to read/write to was being modified by pppd. When pppd takes control of a tty/pty device, it changes the line discipline from N_TTY to N_PPP. This means that when when you open() and then read() or write() to the slave node, the PPP intermediate driver is being used instead of the TTY driver. So, a read() and write() boils down to a totally different function. Looking at the N_PPP driver I found the following. This answers my question as to why EAGAIN was being returned.

Code:
/*
 * Read does nothing - no data is ever available this way.
 * Pppd reads and writes packets via /dev/ppp instead.
 */
static ssize_t
ppp_asynctty_read(struct tty_struct *tty, struct file *file,
          unsigned char __user *buf, size_t count)
{
    return -EAGAIN;
}

/*
 * Write on the tty does nothing, the packets all come in
 * from the ppp generic stuff.
 */
static ssize_t
        ppp_asynctty_write(struct tty_struct *tty, struct file *file,
           const unsigned char *buf, size_t count)
{
    return -EAGAIN;
}
 
  


Reply

Tags
pppd



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Vpn poptop - CTRL: PTY read or GRE write failed (pty,gre)=(5,6) dezeque Linux - Networking 9 08-26-2016 10:39 AM
Problems with dynamic registration of SPI protocol slave devices Brahmsian Linux - Embedded & Single-board computer 1 04-18-2012 01:20 AM
getmaster - no usable host pty devices matthiasbla Debian 0 11-24-2010 02:22 AM
pppd: pty [ usb speedtocuh modem] edM Slackware 10 01-31-2005 05:13 PM
Expect script throws "open(slave pty): bad file number" error KNut Linux - Newbie 0 02-24-2004 12:24 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration