Solved

Attach daemon to a tty

Posted on 1997-04-16
5
1,412 Views
Last Modified: 2013-12-26
I would like to attach a process with no controlling tty to a tty. i.e. the process should be able to open /dev/tty.
I looked in kernel sources (Linux) and did not find any way to do this directly, however I found a mention of slave ptys, which seem like they might do something similar.
Opening /dev/console is not an acceptable solution, as this should be possible to do in the background.
The target application is a SVGALib daemon, drawing to a specified tty on request.
0
Comment
Question by:msharov
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 3

Expert Comment

by:dhm
ID: 1292595
Since the application draws to a tty "on request," couldn't you just include the name of the tty in the request?  The daemon can open the tty named in the request; that terminal becomes the daemon's controlling tty unless you specify extra flags to the open().  (I can dig up the exact flags and other info if this is an acceptable solution.)
0
 

Author Comment

by:msharov
ID: 1292596
That's not true. Only one process group at a time can have the tty as its controlling tty. If you open a used tty, /dev/tty is still owned by the active process in the previous process group and cannot be opened by the daemon.
0
 

Expert Comment

by:wjg
ID: 1292597
Why do you want the terminal you open to write to as your controlling tty? Writing to/Reading from a tty should be possible, even if it is not your controlling tty. (If you use a job-control shell: some of them configure the tty driver to suspend processes that are not in the tty's process group. Usually stty(1) or ioctl(2)/termios(2), or shell builtin commands can be used to allow writing to all processes wanting to do so. See the mesg(1) command, and write(1) as well as wall(1m)).

How are you going to synchronize writes to the user's terminal (i.e. who is 'requesting the drawing' - the user or another daemon)? You should not mess around with the user's current tty settings as these may be from a screen oriented program the user is currently using (like vi/more). If the user calls one of your programs to establish contact to the daemon running in the background this program could either provide information on the process group it is in and the tty name (which is what dhm already noticed) or you could split up work differently by having the user started application do the drawing of data received from the daemon.

0
 

Expert Comment

by:wjg
ID: 1292598
Rereading your question and my comment the following thought just occurred to me: Do you know the difference between /dev/tty (i.e. a pseudo device that maps to the calling users controlling tty) and /dev/tty?* (i.e. devices that represent serial lines or pseudo terminals on the screen)? If you want to use /dev/tty you really do have a problem because what you should be using is the callers *real* terminal as returned by tty(1) - which is the /dev/tty?* variety.
0
 
LVL 4

Accepted Solution

by:
jos010697 earned 200 total points
ID: 1292599
Use pseudo terminals. Check your /dev directory and
see how many pseudo terminals are defined. Every
pseudo terminal is represented by two drivers:

/dev/ptyX   the controlling driver
/dev/ttyX   the slave device driver

if one process opens the controlling driver and another
opens the slave driver, communication between the two
can done by 'pseudo' terminals, i.e. wrtiten data to one device
can be read (by the other process) from the other device.

kind regards,

Jos

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
not able to insert into temp table 68 178
ORA-01403: no data found 43 116
sumDigits challenge 9 178
Not needed 13 134
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question