term_plan9.go 804 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package termutil
  2. import (
  3. "errors"
  4. "os"
  5. "syscall"
  6. )
  7. var (
  8. consctl *os.File
  9. // Plan 9 doesn't have syscall.SIGQUIT
  10. unlockSignals = []os.Signal{
  11. os.Interrupt, syscall.SIGTERM, syscall.SIGKILL,
  12. }
  13. )
  14. // TerminalWidth returns width of the terminal.
  15. func TerminalWidth() (int, error) {
  16. return 0, errors.New("Not supported")
  17. }
  18. func lockEcho() error {
  19. if consctl != nil {
  20. return errors.New("consctl already open")
  21. }
  22. var err error
  23. consctl, err = os.OpenFile("/dev/consctl", os.O_WRONLY, 0)
  24. if err != nil {
  25. return err
  26. }
  27. _, err = consctl.WriteString("rawon")
  28. if err != nil {
  29. consctl.Close()
  30. consctl = nil
  31. return err
  32. }
  33. return nil
  34. }
  35. func unlockEcho() error {
  36. if consctl == nil {
  37. return nil
  38. }
  39. if err := consctl.Close(); err != nil {
  40. return err
  41. }
  42. consctl = nil
  43. return nil
  44. }