LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-10-2008, 05:55 AM   #1
Alien_Hominid
Senior Member
 
Registered: Oct 2005
Location: Lithuania
Distribution: Hybrid
Posts: 2,247

Rep: Reputation: 53
Pseudo terminal programming


I was looking for information about writing a pseudo terminal but information is scarce at best. Actually, I don't need any escape codes emulation just STDIN, STDOUT support.
 
Old 01-11-2008, 12:17 AM   #2
SciYro
Senior Member
 
Registered: Oct 2003
Location: hopefully not here
Distribution: Gentoo
Posts: 2,038

Rep: Reputation: 51
?? Please clarify. Do you need a real terminal connection (such as is necessary for ncurses UI's), or just the ability to input data, and read data from a program (piping).

If its piping, then the best information is contained within the C library documentation from the glibc project. If its the other one, uhhh, i dono why you would do such a thing, but would suggest looking at terminal emulator source codes, such as from xterm, as it sounds like that might be a close match.

So, what exactly is it your trying to do?
 
Old 01-11-2008, 02:24 AM   #3
Alien_Hominid
Senior Member
 
Registered: Oct 2005
Location: Lithuania
Distribution: Hybrid
Posts: 2,247

Original Poster
Rep: Reputation: 53
More like xterm. I found that all the pseudo terminals are based on xterm. But I wonder why it should emulate any of the terminals like vt100 (is it really necessary?). Can't it just act as virtual console (tty 1-6) but on X?

I am looking if it would be possible for me to write a minimalistic pseudo terminal (I didn't find better word to describe it).

There are:
Pseudo terminal
Terminal emulator
Text terminal
Virtual terminal
Virtual console

So I'm a bit confused, which defintion is the right one (or no one).

Thanks for response.
 
Old 01-11-2008, 02:55 PM   #4
SciYro
Senior Member
 
Registered: Oct 2003
Location: hopefully not here
Distribution: Gentoo
Posts: 2,038

Rep: Reputation: 51
ok, look at the libc documentation under "low level terminal interface"->"pseudo terminals" or something like that.

Is it really necessary? No, not really, but if it didn't, then the user couldn't manage the programs connected to the terminal (such as sending kill signals, and other signals). Even the Linux virtual terminals have some of this extra functionality (tho, im not sure if Linux emulates, or has its own terminal trickies).
 
Old 01-12-2008, 06:17 AM   #5
Alien_Hominid
Senior Member
 
Registered: Oct 2005
Location: Lithuania
Distribution: Hybrid
Posts: 2,247

Original Poster
Rep: Reputation: 53
I've read that linux has its own codes, but they are mostly based on vt100. The reason why I don't want go with emulation is that I am afraid with complexity, which follows emulating some terminal types.

I've already looked at http://www.gnu.org/software/libc/man..._002dTerminals that's why I said that information is scarce. For example, when googling there is much more info about writing a shell. The only relevant link was a warning about the complexity of emulation: http://www.cs.utk.edu/~shuford/termi...ow_to_news.txt

Last edited by Alien_Hominid; 01-12-2008 at 06:19 AM.
 
Old 01-20-2008, 04:19 AM   #6
Alien_Hominid
Senior Member
 
Registered: Oct 2005
Location: Lithuania
Distribution: Hybrid
Posts: 2,247

Original Poster
Rep: Reputation: 53
Quote:
CONSOLE(4) Linux Programmer's Manual CONSOLE(4)

NAME
console - console terminal and virtual consoles

DESCRIPTION
A Linux system has up to 63 virtual consoles (character devices with major number 4 and minor number 1 to 63), usually called /dev/ttyn with 1 <= n <= 63. The current console is also addressed by /dev/console or /dev/tty0, the character device with major number 4 and minor number 0. The device files /dev/* are usually created using the script MAKEDEV, or using mknod(1), usually with mode 0622 and owner root.tty.

Before kernel version 1.1.54 the number of virtual consoles was compiled into the kernel (in tty.h: #define NR_CONSOLES 8) and could be changed by editing and recompiling. Since version 1.1.54 virtual consoles are created on the fly, as soon as they are needed.

Common ways to start a process on a console are: (a) tell init(8) (in inittab(5)) to start a getty(8) on the console; (b) ask openvt(1) to start a process on the console; (c) start X -- it will find the first unused console, and display its output there. (There is also the ancient doshell(8).)

Common ways to switch consoles are: (a) use Alt+Fn or Ctrl+Alt+Fn to switch to console n; AltGr+Fn might bring you to console n+12 [here Alt and AltGr refer to the left and right Alt keys, respectively]; (b) use Alt+RightArrow or Alt+Left-Arrow to cycle through the presently allocated consoles; (c) use the program chvt(1). (The key mapping is user set- table, see loadkeys(1); the above mentioned key combinations are according to the default settings.)

The command deallocvt(1) (formerly disalloc) will free the memory taken by the screen buffers for consoles that no longer have any associated process.

PROPERTIES
Consoles carry a lot of state. I hope to document that some other time. The most important fact is that the consoles simulate vt100 terminals. In particular, a console is reset to the initial state by printing the two characters ESC c.
All escape sequences can be found in console_codes(4).

FILES
/dev/console
/dev/tty*

SEE ALSO
chvt(1), deallocvt(1), loadkeys(1), mknod(1), openvt(1), console_codes(4), console_ioctl(4), tty(4), ttyS(4),
charsets(7), getty(8), init(8), mapscrn(8), resizecons(8), setfont(8)

Linux 1994-10-31 CONSOLE(4)

What the hell? 14 years have passed but documentation is not updated. Should I go and read the source code or what?


What's the difference between virtual terminal and virtual console?

Last edited by Alien_Hominid; 01-20-2008 at 04:32 AM.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
pseudo terminal - scp problem vdx Programming 9 08-22-2007 03:37 AM
simulating pseudo master-slave terminal sytem kshkid Programming 2 03-27-2006 07:58 AM
Switch to pseudo terminal you didn't log out of? xnomad Linux - General 2 07-19-2005 12:35 AM
Questions about (Pseudo)Terminal devices beginner16 Programming 0 04-09-2004 10:03 AM
Pseudo Terminal Problems ailiez Programming 2 02-09-2004 01:58 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:58 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