The manual
ginnOS
The reference: libc, the libraries and the kernel
Toggle main menu visibility
Loading...
Searching...
No Matches
pty.h
Go to the documentation of this file.
1
#pragma once
2
3
/**
4
* @file pty.h
5
* @brief pseudo-terminals: /dev/ptmx and /dev/pts/N.
6
*
7
* a terminal app (mimir) opens /dev/ptmx and gets the master side of a new
8
* pair. the program it runs (a shell) uses the slave side, /dev/pts/N, as
9
* its terminal: the same termios settings, job control ioctls and window
10
* size as the console. bytes the master writes go through the slave's line
11
* discipline (line editing, echo, the signal keys) and are read by the
12
* slave; bytes the slave writes are read by the master.
13
*
14
* the user interface is the Linux one: TIOCGPTN gives N, TIOCSPTLCK with 0
15
* unlocks the slave (unlockpt), TIOCSWINSZ sets the size and sends SIGWINCH
16
* to the foreground process group.
17
*
18
* limits: VTIME is not used (a read with VMIN 0 does not wait at all). the
19
* master's writes wait when the slave does not read; a terminal app that
20
* also reads the master in the same thread uses O_NONBLOCK and poll.
21
*/
22
23
#include "
common/stdint.h
"
24
25
struct
device
;
26
27
// the most pairs open at the same time
28
#define PTY_MAX 16
29
30
/**
31
* register /dev/ptmx. call once at boot, after the device registry.
32
*/
33
void
pty_init
(
void
);
34
35
/**
36
* the device of /dev/pts/N (devfs uses it to open the slave side).
37
* @return the device, or NULL if pair N does not exist.
38
*/
39
struct
device
*
pty_slave_device
(
uint32_t
index);
40
41
/**
42
* the lowest pair number at or above *index that exists (devfs lists them).
43
* @param index in: where to start; out: the pair found.
44
* @return false if there is none.
45
*/
46
bool
pty_next
(
uint32_t
*index);
stdint.h
uint32_t
unsigned int uint32_t
Definition
fb.h:17
pty_init
void pty_init(void)
register /dev/ptmx.
Definition
pty.c:992
pty_next
bool pty_next(uint32_t *index)
the lowest pair number at or above *index that exists (devfs lists them).
Definition
pty.c:1031
pty_slave_device
device_t * pty_slave_device(uint32_t index)
the device of /dev/pts/N (devfs uses it to open the slave side).
Definition
pty.c:1019
device
a registered device.
Definition
device.h:114
src
kernel
tty
pty.h
Generated by
1.18.0