|
|
1.1 ! root 1: .TH STREAM 4 ! 2: .CT 2 comm_proc ! 3: .SH NAME ! 4: stream \- communication channels ! 5: .SH SYNOPSIS ! 6: .B #include <sys/filio.h> ! 7: .br ! 8: .B #include <sys/ttyio.h> ! 9: .SH DESCRIPTION ! 10: A stream is a connection between two processes, or between a process ! 11: and a device. ! 12: It is referred to by a file descriptor, and ordinary read and write ! 13: calls apply. ! 14: When a write ! 15: call is given on a stream whose other end has disappeared, ! 16: for example because the process at other end of a pipe has terminated, ! 17: or a device has hung up, signal ! 18: .B SIGPIPE ! 19: is generated; if the signal is ignored, ! 20: the write call returns error ! 21: .BR EPIPE . ! 22: The first 64 ! 23: attempts to read such a disconnected stream ! 24: return 0; ! 25: subsequent attempts generate ! 26: .B SIGPIPE ! 27: signals. ! 28: .PP ! 29: Pipes are streams; ! 30: so are most communication devices ! 31: like terminals and networks. ! 32: .PP ! 33: Line disciplines may be inserted into a stream ! 34: to do various sorts of processing. ! 35: Line disciplines within a stream ! 36: are identified by their position; ! 37: level 0 is nearest the process. ! 38: Line disciplines on ! 39: one end of a pipe cannot be seen from the other. ! 40: Line discipline types are integers; ! 41: a list is given below. ! 42: .PP ! 43: These ! 44: .I ioctl ! 45: calls, ! 46: defined in ! 47: .BR <sys/filio.h> , ! 48: manipulate line disciplines: ! 49: .nr pW \w'\f3FIOPUSHLD 'u ! 50: .TP \n(pWu ! 51: .B FIOPUSHLD ! 52: The third argument points to an integer naming a line discipline; ! 53: insert that line discipline ! 54: at level 0. ! 55: .PD ! 56: .TP ! 57: .B FIOINSLD ! 58: The third argument points to a structure: ! 59: .RS ! 60: .LP ! 61: .EX ! 62: struct insld { ! 63: short ld; ! 64: short level; ! 65: }; ! 66: .EE ! 67: .LP ! 68: Insert the line discipline named by ! 69: .B ld ! 70: in the stream ! 71: at ! 72: depth ! 73: .BR level . ! 74: If there are fewer than ! 75: .B level ! 76: line disciplines in the stream, ! 77: an error is returned. ! 78: .RE ! 79: .TP ! 80: .B FIOPOPLD ! 81: The third argument points to an integer; ! 82: remove the line discipline at that level in the stream. ! 83: A null pointer ! 84: (the usual case) ! 85: means level 0. ! 86: .TP ! 87: .B FIOLOOKLD ! 88: The third argument ! 89: points to an integer; ! 90: return the type of the line discipline at that level, ! 91: both in the same integer ! 92: and as the return value from ! 93: .IR ioctl . ! 94: A null pointer means level 0. ! 95: .PP ! 96: These ! 97: .I ioctl ! 98: calls, ! 99: also in ! 100: .BR <sys/filio.h> , ! 101: perform other operations on streams: ! 102: .TP \n(pWu ! 103: .B FIOSNDFD ! 104: The third argument points to an integer ! 105: naming an open file descriptor. ! 106: Send a reference to that file ! 107: to the other end of the stream. ! 108: This works only on pipes. ! 109: The reference is unaffected by intervening line disciplines; ! 110: in particular it cannot be intercepted or forged by ! 111: .IR mesgld (4). ! 112: .B FIOSNDFD ! 113: returns immediately; ! 114: it does not wait for the reference to be received. ! 115: .TP ! 116: .B FIORCVFD ! 117: The third argument points to a structure: ! 118: .RS ! 119: .LP ! 120: .EX ! 121: struct passfd { ! 122: int fd; ! 123: short uid; ! 124: short gid; ! 125: short nice; ! 126: char logname[8]; ! 127: }; ! 128: .EE ! 129: .PP ! 130: Receive a file reference sent by ! 131: .BR FIOSNDFD ; ! 132: fill in the structure with a file descriptor ! 133: .B fd ! 134: for the passed file, ! 135: and the userid ! 136: .BR uid , ! 137: groupid ! 138: .BR gid , ! 139: login name ! 140: .BR logname , ! 141: and scheduling priority ! 142: .BR nice ! 143: of the sending process. ! 144: The file reference must be the next message in the stream; ! 145: if data precedes it, ! 146: .B EIO ! 147: is returned. ! 148: If the stream is empty, ! 149: .B FIORCVFD ! 150: blocks until data or a file reference arrives. ! 151: .RE ! 152: .TP ! 153: .B FIONREAD ! 154: The third argument ! 155: points to an integer; ! 156: fill it in with the number of characters ! 157: that may be read from this stream without blocking. ! 158: .PP ! 159: These ! 160: .I ioctl ! 161: calls also work on streams, ! 162: but are defined in ! 163: .BR <sys/ttyio.h> ! 164: for historic reasons: ! 165: .TP \n(pWu ! 166: .B TIOCSPGRP ! 167: The third argument points to a short integer. ! 168: If the pointer is null ! 169: (the usual case), ! 170: make a new process group for the current process, ! 171: and associate the group with this stream. ! 172: If the pointer is not null, ! 173: it points to a process group id; ! 174: associate that group with this stream. ! 175: When the lowest level of a stream ! 176: receives a signal message ! 177: (like ! 178: .B SIGINT ! 179: or ! 180: .B SIGQUIT ! 181: from ! 182: .IR ttyld (4)), ! 183: the signal is sent to processes in the associated process group. ! 184: If the stream is shut down prematurely, ! 185: the process group is sent ! 186: .BR SIGHUP . ! 187: .TP ! 188: .B TIOCGPGRP ! 189: The third argument points to a short integer; ! 190: fill it in with the process group id associated with this stream. ! 191: 0 means no group. ! 192: .TP ! 193: .B TIOCEXCL ! 194: Mark this stream ! 195: so that future opens are forbidden ! 196: except to the super-user ! 197: or to processes in the associated process group. ! 198: .TP ! 199: .B TIOCNXCL ! 200: Remove the mark left by ! 201: .BR TIOCEXCL . ! 202: .TP ! 203: .B TIOCSBRK ! 204: Send a break on a serial line. ! 205: .TP ! 206: .B TIOCFLUSH ! 207: Throw away queued data anywhere in the stream. ! 208: .LP ! 209: Here is a list of line discipline types. ! 210: The names refer to global integers ! 211: defined in the C library. ! 212: .TP \n(pWu ! 213: .PD 0 ! 214: .B tty_ld ! 215: Regular terminal processing, ! 216: .IR ttyld (4). ! 217: .TP ! 218: .B ntty_ld ! 219: Restricted Berkeley `new tty' terminal processing; ! 220: see the Berkeley Users Manual. ! 221: .TP ! 222: .B cdkp_ld ! 223: Character-mode Datakit universal receiver protocol, ! 224: .IR dk (4). ! 225: .TP ! 226: .B dkp_ld ! 227: Block-mode Datakit universal receiver protocol, ! 228: .IR dk (4). ! 229: .TP ! 230: .B rdk_ld ! 231: .TP ! 232: .B uxp_ld ! 233: Datakit protocols used in call setup, ! 234: .IR dk (4). ! 235: .TP ! 236: .B buf_ld ! 237: Buffering mechanism, ! 238: .IR bufld (4). ! 239: .TP ! 240: .B mesg_ld ! 241: .TP ! 242: .B rmesg_ld ! 243: Turn stream controls into ordinary data and vice versa, ! 244: .IR mesgld (4). ! 245: .TP ! 246: .B conn_ld ! 247: Make unique connections to a server, ! 248: .IR connld (4). ! 249: .TP ! 250: .B ip_ld ! 251: .TP ! 252: .B tcp_ld ! 253: .TP ! 254: .B udp_ld ! 255: Internet protocols, ! 256: .IR internet (3). ! 257: .SH SEE ALSO ! 258: .IR ioctl (2), ! 259: .IR signal (2), ! 260: .IR mesgld (4), ! 261: .IR ipc (3) ! 262: .br ! 263: D. M. Ritchie, ! 264: `A Stream I/O System', ! 265: this manual, Volume 2
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.