n_tty_write(9)
π n_tty_write(9) β like, the write function for tty, bestie
okay so real quick, this is from the Kernel API Manual (the kernel API girlies know), and it's literally the write function for a tty. buckle up π
β¨ NAME β¨
n_tty_write β the write function for tty. that's it, that's the vibe. π
πΈ SYNOPSIS πΈ
ssize_t n_tty_write (struct tty_struct *tty , struct file *file , const
u8 *buf , size_t nr );
π¦ ARGUMENTS π¦
ttyβ the tty device. the main character of this whole situation πfileβ the file object, standard issuebufβ a userspace buffer pointer, so like, pointers into userspace, mwah πnrβ the size of I/O, aka how much we're moving
π DESCRIPTION π
okay so this is the write function of the terminal device, periodt. here's the tea: it's serialized with respect to other write callers β but not to termios changes, reads, and other such events. so it plays nice with other writers and only other writers, iykyk π
and because the receive code will echo characters (which means it goes and calls the driver write methods!!), the output_lock is used in the output processing functions called here and in the echo processing function, to protect the column state and the space left in the buffer. teamwork, no cap π«Ά
β οΈ this code must be sure never to sleep through a hangup. like, fr fr, that's a hard requirement, don't do it π
π₯ Locking
output_lock protects the column state and the space left β and note that the process_output*() functions take this lock themselves, so don't go double-locking, bestie π
π SEE ALSO π
kernel file ./drivers/tty/n_tty.c β and honestly the whole friend group:
n_tty_kick_worker(9)n_tty_write_wakeup(9)put_tty_queue(9)reset_buffer_flags(9)n_tty_flush_buffer(9)is_utf8_continuation(9)is_continuation(9)do_output_char(9)process_output(9)process_output_block(9)__process_echoes(9)add_echo_byte(9)echo_move_back_col(9)echo_set_canon_col(9)echo_erase_tab(9)echo_char_raw(9)echo_char(9)finish_erasing(9)eraser(9)isig(9)n_tty_receive_break(9)n_tty_receive_overrun(9)n_tty_receive_parity_error(9)n_tty_receive_char_flow_ctrl(9)n_tty_receive_char(9)n_tty_receive_buf_common(9)n_tty_set_termios(9)n_tty_close(9)n_tty_open(9)copy_from_read_buf(9)canon_copy_from_read_buf(9)job_control(9)n_tty_read(9)n_tty_poll(9)n_tty_inherit_ops(9)
and that's the page, bestie π§β¨ this icon came from ./drivers/tty, dated October 2026, and it's giving absolute legend behavior β go off, kernel docs πππ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms