forktty(8)

πŸ“¦ version 1.3, in nixos 26.05, nixpkgs unstable

forktty πŸ’…

okay bestie, this is forktty(8) β€” yes, section 8, from the System Manager's Manual. she's a tiny little icon and she wants to attach a program to a CTTY. no cap. ✨

🌸 NAME 🌸

forktty β€” attach a program to a CTTY. periodt. πŸ’–

πŸ¦‹ SYNOPSIS πŸ¦‹

forktty [-dhnpVvw] [-l /dev/tty??] [-c command] prog_to_run

✨ DESCRIPTION ✨

forktty is a tiny little program that can be used to run a program in a new session. The program forks, redirects stdin to /dev/null β€” which returns the prompt β€” disconnects from the controlling terminal, optionally connects to a user-specified terminal, and runs a program. it's giving main character energy for background processes, fr fr. πŸ’…

πŸŽ€ OPTIONS πŸŽ€

  • -c command β€” execute bash -c command in the new session. 🫢
  • -d β€” prepend a dash - to the program name passed in argument 0. used for login shells. πŸ’–
  • -f β€” fork only, do not use setsid() nor NOCTTY to disconnect from the current CTTY.
  • --fdi <int>, --fdo <int>, --fde <int> β€” copy stdin, stdout or stderr, into a file descriptor <int> using dup2(2). Thus, a backgrounded program may interact via those new fd's. The values 0,1,2 are reserved and closed during the fork. 🫢
  • -h β€” print a help message. πŸŽ€
  • -l /dev/tty?? β€” connect to terminal /dev/tty??; &<int> uses the file descriptor <int>. πŸ¦‹
  • -n β€” don't initialize terminal. the tty is not set in raw -echo mode. See stty(1). 🌸
  • -p β€” pipe stdin and stdout to the terminal.
  • -r β€” use open(NONBLOCK) stty() close() open() sequence. ✨
  • --sane β€” initialize the tty in VT style echo mode.
  • -v β€” enable verbose output. repeat to increase the verbosity. πŸ”₯
  • -V β€” report version. πŸ‘‘
  • -w β€” wait for child program termination before exit.

The program runs with stdin redirected to /dev/null if no new terminal is given. πŸ’œ

🌈 EXAMPLES 🌈

forktty --sane -l /dev/ttyS0 -- lynx -restriction=all
forktty -n -l /dev/ttyS0 -c 'reset && exec lynx -restrictions=all'
forktty -n -l /dev/ttyS0 -- bash -c 'reset && exec lynx
-restrictions=all'
forktty -c 'sleep 1; echo $0'
forktty -d -c 'sleep 1; echo $0'
forktty -d -- bash -c 'sleep 1; echo $0'
forktty -- bash -login -c 'sleep 1; echo $0'

πŸ’€ BUGS πŸ’€

None known. literally none, bestie. not a single one. πŸ’€

πŸ¦‹ SEE ALSO πŸ¦‹

fork(2), setsid(2) β€” go read them, iykyk. πŸ¦‹


πŸ’– source: System Manager's Manual Β· manual: forktty(8) Β· date: 28 Sep 2002 β€” mwah, bestie, go be iconic. πŸ’‹

πŸ“¦ where this page comes from