?
Solved

Attach daemon to a tty

Posted on 1997-04-16
5
Medium Priority
?
1,450 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 400 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

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

800 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