Changeset 13118 in project


Ignore:
Timestamp:
01/27/09 02:11:21 (11 years ago)
Author:
Kon Lovett
Message:

Added more terminal control. Chgd some names.

Location:
release/3/posix-extensions/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/3/posix-extensions/trunk/4unix.scm

    r13092 r13118  
    11;;;; 4unix.scm
    2 ;;;; Kon Lovett, Sep '06
     2;;;; Kon Lovett, Jan '09
    33;;;; Alaric Snell-Pym, Jan '09
    44
    55;; Issues
     6;;
     7;; - HP-UX, SunOS & Solaris support is spotty.
    68;;
    79;; - Assumes whitespace before & after C pre-processor leading '#' is legal.
    810;;
    9 ;; - The termios struct interface is conditioned on MacOS X, where I know the i/ospeed
    10 ;; elements are defined.
     11;; - Should have OS specific extension module for stuff like MacOS X 'prio/darwin-thread'.
    1112;;
    12 ;; This can be done better - actually check for the field's existence in the
    13 ;; .setup w/ a 'try-compile' & then pass info as a '-feature SYMBOL'.
     13;; - Assumes id_t, pid_t, gid_t, & uid_t all are representable by a FIXNUM!
    1414;;
    15 ;; - Should have OS specific extensions for stuff like MacOS X 'priority/darwin-thread'.
     15;; - The EINTR condition (system call interrupted) is not handled.
    1616;;
    17 ;; - Should use abstract types like 'pid_t' and 'id_t'.
     17;; Should retry operation until success/failure or retry count is exceeded.
    1818
    1919(declare
     
    4949    change-file-times
    5050    ;
    51     priority/process
    52     priority/process-group
    53     priority/user
    54     priority/darwin-thread
    55     priority/darwin-bg
     51    prio/process
     52    prio/process-group
     53    prio/user
     54    prio/darwin-thread
     55    prio/darwin-bg
    5656    scheduling-priority
    5757    set-scheduling-priority!
    5858    ;
    59     alloc-termios
    60     free-termios
    61     termios-cc
    62     termios-cc-set!
    63     termios-cflag
    64     termios-cflag-set!
    65     termios-iflag
    66     termios-iflag-set!
    67     termios-ispeed
    68     termios-ispeed-set!
    69     termios-lflag
    70     termios-lflag-set!
    71     termios-oflag
    72     termios-oflag-set!
    73     termios-ospeed
    74     termios-ospeed-set!
     59    make-winsize
    7560    alloc-winsize
    7661    free-winsize
     
    8469    winsize-ypixel-set!
    8570    ;
    86     openpty
     71    make-termios
     72    alloc-termios
     73    free-termios
     74    termios-iflag
     75    termios-iflag-set!
     76    termios-oflag
     77    termios-oflag-set!
     78    termios-cflag
     79    termios-cflag-set!
     80    termios-lflag
     81    termios-lflag-set!
     82    termios-cc
     83    termios-cc-set!
     84    termios/nccs
     85    ;
     86    terminal-control-input-speed
     87    terminal-control-output-speed
     88    set-terminal-control-input-speed!
     89    set-terminal-control-output-speed!
     90    set-terminal-control-speed!
     91    ;
     92    terminal-control-attributes
     93    set-terminal-control-attributes!
     94    ;
     95    terminal-control-drain
     96    terminal-control-flow
     97    terminal-control-flush
     98    terminal-control-send-break
     99    terminal-control-make-raw
     100    ;
     101    open-pseudo-tty
    87102    login-tty
    88     forkpty
    89     ;
    90                 isatty
    91                 ttyname
    92                 ttyslot
     103    fork-pseudo-tty
     104    ;
     105                terminal-type-device?
     106                terminal-device-name
     107                current-process-tty-number
    93108    ;
    94109    replace-fileno ) )
    95110
    96111(require-extension posix)
     112(require-extension miscmacros)
    97113
    98114;;;
     
    118134  ] )
    119135
    120 
    121 (define-foreign-variable _null c-pointer "NULL")
     136;;;
     137
     138#<
     139#define C_locative_address( l ) (C_block_item( (l), 0 ))
     140
     141#define C_locative_cast( t, l ) ((t *)C_locative_address( l ))
     142
     143#define C_pointer_cast( t, p )  ((t *)C_pointer_address( p ))
     144>#
     145
     146(define _null (##sys#null-pointer))
     147
     148(define (##sys#check-pointer obj #!optional loc)
     149  (unless (##sys#pointer? obj)
     150    (##sys#signal-hook #:type-error loc "bad argument type - not a pointer" obj) ) )
     151
     152(define (##sys#check-pointer-argument obj #!optional loc)
     153  (unless (or (##sys#pointer? obj) (not obj))
     154    (##sys#signal-hook #:type-error loc "bad argument type - not a pointer or #f" obj) ) )
    122155
    123156;;; Errno
     
    171204  (##sys#check-string fname 'change-link-mode)
    172205  (##sys#check-exact mode 'change-link-mode)
    173   (when (fx< (##core#inline "C_lchmod" (##sys#make-c-string (##sys#expand-home-path fname)) mode) 0)
     206  (when (fx= -1 (##core#inline "C_lchmod" (##sys#make-c-string (##sys#expand-home-path fname)) mode))
    174207    (##sys#posix-error #:file-error 'change-link-mode "cannot change link mode" fname mode) ) )
    175208
     
    178211  (##sys#check-exact uid 'change-link-owner)
    179212  (##sys#check-exact gid 'change-link-owner)
    180   (when (fx< (##core#inline "C_lchown" (##sys#make-c-string (##sys#expand-home-path fname)) uid gid) 0)
     213  (when (fx= -1 (##core#inline "C_lchown" (##sys#make-c-string (##sys#expand-home-path fname)) uid gid))
    181214    (##sys#posix-error #:file-error 'change-link-owner "cannot change link owner" fname uid gid) ) )
    182215
     
    185218  (##sys#check-exact mode 'change-link-owner)
    186219  (##sys#check-exact devnum 'change-link-owner)
    187   (when (fx< (##core#inline "C_mknod" (##sys#make-c-string (##sys#expand-home-path fname)) mode devnum) 0)
     220  (when (fx= -1 (##core#inline "C_mknod" (##sys#make-c-string (##sys#expand-home-path fname)) mode devnum))
    188221    (##sys#posix-error #:file-error 'make-special-file "cannot make special file" fname mode devnum) ) )
    189222
     
    194227  (set! _utime_atime atime)
    195228  (set! _utime_mtime mtime)
    196   (when (fx< (##core#inline "C_utime" (##sys#make-c-string (##sys#expand-home-path fname))) 0)
     229  (when (fx= -1 (##core#inline "C_utime" (##sys#make-c-string (##sys#expand-home-path fname))))
    197230     (##sys#posix-error #:file-error 'change-file-times "cannot change file times" fname atime mtime) ) )
    198231
     
    200233
    201234#>
    202 //#include <sys/time.h>
     235#include <sys/time.h> /* for portability */
    203236#include <sys/resource.h>
    204 <#
    205 
    206 (define priority/process (foreign-value "PRIO_PROCESS" int))
    207 (define priority/process-group (foreign-value "PRIO_PGRP" int))
    208 (define priority/user (foreign-value "PRIO_USER" int))
     237
     238#define C_getpriority( wi, wo )     C_fix( getpriority( C_unfix( wi ), (id_t)C_unfix( wo ) ) )
     239#define C_setpriority( wi, wo, pr ) C_fix( setpriority( C_unfix( wi ), (id_t)C_unfix( wo ), C_unfix( pr ) ) )
     240<#
     241
     242(define prio/process (foreign-value "PRIO_PROCESS" int))
     243(define prio/process-group (foreign-value "PRIO_PGRP" int))
     244(define prio/user (foreign-value "PRIO_USER" int))
    209245(cond-expand
    210246  [macosx
    211     (define priority/darwin-thread (foreign-value "PRIO_DARWIN_THREAD" int))
    212     (define priority/darwin-bg (foreign-value "PRIO_DARWIN_BG" int))
     247    (define prio/darwin-thread (foreign-value "PRIO_DARWIN_THREAD" int))
     248    (define prio/darwin-bg (foreign-value "PRIO_DARWIN_BG" int))
    213249  ] [else
    214     (define priority/darwin-thread 0)
    215     (define priority/darwin-bg 0)
     250    (define prio/darwin-thread 0)
     251    (define prio/darwin-bg 0)
    216252  ] )
    217253
    218 (define scheduling-priority
    219   (let ([get-priority (foreign-lambda int "getpriority" int int)])
    220     (lambda (which who)
    221       (set! _errno 0)
    222       (let ([res (get-priority which who)])
    223         (when (and (negative? res) (not (zero? _errno)))
    224           (##sys#update-errno)
    225           (##sys#error 'scheduling-priority "get priority failed" which who))
    226         res) ) ) )
    227 
    228 (define set-scheduling-priority!
    229   (let ([set-priority! (foreign-lambda int "setpriority" int int int)])
    230     (lambda (which who prio)
    231       (let ([res (set-priority! which who prio)])
    232         (when (fx< res 0)
    233           (##sys#update-errno)
    234           (##sys#error 'set-scheduling-priority! "set priority failed" which who prio)) ) ) ) )
     254(define (scheduling-priority which who)
     255  (set! _errno 0)
     256  (let ([res (##core#inline "C_getpriority" which who)])
     257    (if (and (fx< res 0) (not (fx= 0 _errno)))
     258      (##sys#posix-error #:process-error 'scheduling-priority "cannot get process priority" which who)
     259      res ) ) )
     260
     261(define (set-scheduling-priority! which who prio)
     262  (let ([res (##core#inline "C_setpriority" which who prio)])
     263    (when (fx= -1 res 0)
     264      (##sys#posix-error #:process-error 'set-scheduling-priority! "cannot set process priority" which who prio) ) ) )
    235265
    236266;;; Termios & Winsize Records
     
    240270#include <unistd.h>
    241271<#
     272
     273;; Winsize
    242274
    243275; ws_row                                rows, in characters
     
    255287  (unsigned-short        ws_ypixel) )
    256288
     289(define (make-winsize #!key (rows 0) (columns 0) (xpixels 0) (ypixels 0))
     290  (##sys#check-exact rows 'make-winsize)
     291  (##sys#check-exact columns 'make-winsize)
     292  (##sys#check-exact xpixels 'make-winsize)
     293  (##sys#check-exact ypixels 'make-winsize)
     294  (let ([ws (alloc-winsize)])
     295    (winsize-row-set! ws rows)
     296    (winsize-col-set! ws columns)
     297    (winsize-xpixel-set! ws xpixels)
     298    (winsize-ypixel-set! ws ypixels)
     299    (set-finalizer! ws free-winsize)
     300    ws ) )
     301
     302;; Termios
     303
    257304(define-foreign-type tcflag_t unsigned-long)
    258305(define-foreign-type cc_t unsigned-char)
    259306(define-foreign-type speed_t unsigned-long)
    260 (define-foreign-variable NCCS int "NCCS")
    261 
     307
     308(define-foreign-variable IGNBRK tcflag_t "IGNBRK")
     309(define-foreign-variable BRKINT tcflag_t "BRKINT")
     310(define-foreign-variable IGNPAR tcflag_t "IGNPAR")
     311(define-foreign-variable PARMRK tcflag_t "PARMRK")
     312(define-foreign-variable INPCK tcflag_t "INPCK")
     313(define-foreign-variable ISTRIP tcflag_t "ISTRIP")
     314(define-foreign-variable INLCR tcflag_t "INLCR")
     315(define-foreign-variable IGNCR tcflag_t "IGNCR")
     316(define-foreign-variable ICRNL tcflag_t "ICRNL")
     317(define-foreign-variable IXON tcflag_t "IXON")
     318(define-foreign-variable IXOFF tcflag_t "IXOFF")
     319(define-foreign-variable IXANY tcflag_t "IXANY")
    262320(cond-expand
    263321  [macosx
    264 
    265     ; c_iflag                   input flags
    266     ; c_oflag                   output flags
    267     ; c_cflag                   control flags
    268     ; c_lflag                   local flags
    269     ; c_cc                              control chars
    270     ; c_ispeed          input speed
    271     ; c_ospeed          output speed
    272 
    273     (define-foreign-record (termios "struct termios")
    274       (rename: (cut string-translate* <> '(("c_" . ""))))
    275       (constructor: alloc-termios)
    276       (destructor: free-termios)
    277       (tcflag_t c_iflag)
    278       (tcflag_t c_oflag)
    279       (tcflag_t c_cflag)
    280       (tcflag_t c_lflag)
    281       (cc_t c_cc NCCS)
    282       (speed_t c_ispeed)
    283       (speed_t c_ospeed) )
    284 
    285   ] [else
    286 
    287     ; c_iflag                   input flags
    288     ; c_oflag                   output flags
    289     ; c_cflag                   control flags
    290     ; c_lflag                   local flags
    291     ; c_cc                              control chars
    292 
    293     (define-foreign-record (termios "struct termios")
    294       (rename: (cut string-translate* <> '(("c_" . ""))))
    295       (constructor: alloc-termios)
    296       (destructor: free-termios)
    297       (tcflag_t c_iflag)
    298       (tcflag_t c_oflag)
    299       (tcflag_t c_cflag)
    300       (tcflag_t c_lflag)
    301       (cc_t c_cc NCCS) )
    302 
    303     (define-unimplemented termios-ispeed)
    304     (define-unimplemented termios-ispeed-set!)
    305     (define-unimplemented termios-ospeed)
    306     (define-unimplemented termios-ospeed-set!)
    307 
    308  ] )
     322    (define-foreign-variable IMAXBEL tcflag_t "IMAXBEL")
     323    (define-foreign-variable IUTF8 tcflag_t "IUTF8")
     324  ] [else] )
     325
     326(define-foreign-variable OPOST tcflag_t "OPOST")
     327(define-foreign-variable ONLCR tcflag_t "ONLCR")
     328(define-foreign-variable OCRNL tcflag_t "OCRNL")
     329(define-foreign-variable ONOCR tcflag_t "ONOCR")
     330(define-foreign-variable ONLRET tcflag_t "ONLRET")
     331(define-foreign-variable OFILL tcflag_t "OFILL")
     332(define-foreign-variable NLDLY tcflag_t "NLDLY")
     333    (define-foreign-variable NL0 tcflag_t "NL0")
     334    (define-foreign-variable NL1 tcflag_t "NL1")
     335(cond-expand
     336  [macosx
     337        (define-foreign-variable NL2 tcflag_t "NL2")
     338        (define-foreign-variable NL3 tcflag_t "NL3")
     339  ] [else] )
     340(define-foreign-variable TABDLY tcflag_t "TABDLY")
     341    (define-foreign-variable TAB0 tcflag_t "TAB0")
     342    (define-foreign-variable TAB1 tcflag_t "TAB1")
     343    (define-foreign-variable TAB2 tcflag_t "TAB2")
     344    (define-foreign-variable TAB3 tcflag_t "TAB3")
     345(define-foreign-variable CRDLY tcflag_t "CRDLY")
     346    (define-foreign-variable CR0 tcflag_t "CR0")
     347    (define-foreign-variable CR1 tcflag_t "CR1")
     348    (define-foreign-variable CR2 tcflag_t "CR2")
     349    (define-foreign-variable CR3 tcflag_t "CR3")
     350(define-foreign-variable FFDLY tcflag_t "FFDLY")
     351    (define-foreign-variable FF0 tcflag_t "FF0")
     352    (define-foreign-variable FF1 tcflag_t "FF1")
     353(define-foreign-variable BSDLY tcflag_t "BSDLY")
     354    (define-foreign-variable BS0 tcflag_t "BS0")
     355    (define-foreign-variable BS1 tcflag_t "BS1")
     356(define-foreign-variable VTDLY tcflag_t "VTDLY")
     357    (define-foreign-variable VT0 tcflag_t "VT0")
     358    (define-foreign-variable VT1 tcflag_t "VT1")
     359(define-foreign-variable OFDEL tcflag_t "OFDEL")
     360(cond-expand
     361  [macosx
     362    (define-foreign-variable OXTABS tcflag_t "OXTABS")
     363    (define-foreign-variable ONOEOT tcflag_t "ONOEOT")
     364  ] [else] )
     365
     366(define-foreign-variable CSIZE tcflag_t "CSIZE")
     367    (define-foreign-variable CS5 tcflag_t "CS5")
     368    (define-foreign-variable CS6 tcflag_t "CS6")
     369    (define-foreign-variable CS7 tcflag_t "CS7")
     370    (define-foreign-variable CS8 tcflag_t "CS8")
     371(define-foreign-variable CSTOPB tcflag_t "CSTOPB")
     372(define-foreign-variable CREAD tcflag_t "CREAD")
     373(define-foreign-variable PARENB tcflag_t "PARENB")
     374(define-foreign-variable PARODD tcflag_t "PARODD")
     375(define-foreign-variable HUPCL tcflag_t "HUPCL")
     376(define-foreign-variable CLOCAL tcflag_t "CLOCAL")
     377(cond-expand
     378  [macosx
     379    (define-foreign-variable CIGNORE tcflag_t "CIGNORE")
     380    (define-foreign-variable CCTS_OFLOW tcflag_t "CCTS_OFLOW")
     381    (define-foreign-variable CRTSCTS tcflag_t "CRTSCTS")
     382    (define-foreign-variable CRTS_OFLOW tcflag_t "CRTS_OFLOW")
     383    (define-foreign-variable CDTR_OFLOW tcflag_t "CDTR_OFLOW")
     384    (define-foreign-variable CDSR_OFLOW tcflag_t "CDSR_OFLOW")
     385    (define-foreign-variable CCAR_OFLOW tcflag_t "CCAR_OFLOW")
     386    (define-foreign-variable MDMBUF tcflag_t "MDMBUF")
     387  ] [else] )
     388
     389(define-foreign-variable ECHOE tcflag_t "ECHOE")
     390(define-foreign-variable ECHOK tcflag_t "ECHOK")
     391(define-foreign-variable ECHO tcflag_t "ECHO")
     392(define-foreign-variable ECHONL tcflag_t "ECHONL")
     393(define-foreign-variable ISIG tcflag_t "ISIG")
     394(define-foreign-variable ICANON tcflag_t "ICANON")
     395(define-foreign-variable IEXTEN tcflag_t "IEXTEN")
     396(define-foreign-variable TOSTOP tcflag_t "TOSTOP")
     397(define-foreign-variable NOFLSH tcflag_t "NOFLSH")
     398(cond-expand
     399  [macosx
     400    (define-foreign-variable ECHOKE tcflag_t "ECHOKE")
     401    (define-foreign-variable ECHOPRT tcflag_t "ECHOPRT")
     402    (define-foreign-variable ECHOCTL tcflag_t "ECHOCTL")
     403    (define-foreign-variable ALTWERASE tcflag_t "ALTWERASE")
     404    (define-foreign-variable EXTPROC tcflag_t "EXTPROC")
     405    (define-foreign-variable FLUSHO tcflag_t "FLUSHO")
     406    (define-foreign-variable NOKERNINFO tcflag_t "NOKERNINFO")
     407    (define-foreign-variable PENDIN tcflag_t "PENDIN")
     408  ] [else] )
     409
     410(define-foreign-variable VEOF unsigned-short "VEOF")
     411(define-foreign-variable VEOL unsigned-short "VEOL")
     412(define-foreign-variable VERASE unsigned-short "VERASE")
     413(define-foreign-variable VKILL unsigned-short "VKILL")
     414(define-foreign-variable VINTR unsigned-short "VINTR")
     415(define-foreign-variable VQUIT unsigned-short "VQUIT")
     416(define-foreign-variable VSUSP unsigned-short "VSUSP")
     417(define-foreign-variable VSTART unsigned-short "VSTART")
     418(define-foreign-variable VSTOP unsigned-short "VSTOP")
     419(define-foreign-variable VMIN unsigned-short "VMIN")
     420(define-foreign-variable VTIME unsigned-short "VTIME")
     421(cond-expand
     422  [macosx
     423    (define-foreign-variable VEOL2 unsigned-short "VEOL2")
     424    (define-foreign-variable VWERASE unsigned-short "VWERASE")
     425    (define-foreign-variable VREPRINT unsigned-short "VREPRINT")
     426    (define-foreign-variable VDSUSP unsigned-short "VDSUSP")
     427    (define-foreign-variable VLNEXT unsigned-short "VLNEXT")
     428    (define-foreign-variable VDISCARD unsigned-short "VDISCARD")
     429    (define-foreign-variable VSTATUS unsigned-short "VSTATUS")
     430  ] [else] )
     431(define-foreign-variable _nccs unsigned-short "NCCS")
     432(define termios/nccs _nccs)
     433
     434; c_iflag                       input flags
     435; c_oflag                       output flags
     436; c_cflag                       control flags
     437; c_lflag                       local flags
     438; c_cc                          control chars
     439
     440(define-foreign-record (termios "struct termios")
     441  (rename: (cut string-translate* <> '(("c_" . ""))))
     442  (constructor: alloc-termios)
     443  (destructor: free-termios)
     444  (tcflag_t c_iflag)
     445  (tcflag_t c_oflag)
     446  (tcflag_t c_cflag)
     447  (tcflag_t c_lflag)
     448  (cc_t c_cc NCCS) )
     449
     450(define (make-termios #!key (iflags 0) (oflags 0) (cflags 0) (lflags 0) cc)
     451  (##sys#check-exact iflags 'make-termios)
     452  (##sys#check-exact oflags 'make-termios)
     453  (##sys#check-exact cflags 'make-termios)
     454  (##sys#check-exact lflags 'make-termios)
     455  (let ([tr (alloc-termios)])
     456
     457    (define (setcc! len getter)
     458      (dotimes (idx (fxmin _nccs len)) (termios-cc-set! tr idx val)) )
     459
     460    (termios-iflag-set! tr iflags)
     461    (termios-oflag-set! tr oflags)
     462    (termios-cflag-set! tr cflags)
     463    (termios-lflag-set! tr lflags)
     464    (set-finalizer! tr free-termios)
     465    (cond
     466      [(not cc)       (setcc! _nccs (lambda _ 0))]
     467      [(list? cc)     (setcc! (length cc) list-ref)]
     468      [(vector? cc)   (setcc! (vector-length cc) vector-ref)]
     469      [(string? cc)   (setcc! (string-length cc) (lambda (x i) (char->integer (string-ref x i))))]
     470      [else
     471        (##sys#signal-hook #:type-error 'make-termios "bad argument type - not a list, vector, or string" cc) ] )
     472    tr ) )
     473
     474;; Termios access
     475
     476(define-foreign-variable B0 speed_t "B0")
     477(define-foreign-variable B50 speed_t "B50")
     478(define-foreign-variable B75 speed_t "B75")
     479(define-foreign-variable B110 speed_t "B110")
     480(define-foreign-variable B134 speed_t "B134")
     481(define-foreign-variable B150 speed_t "B150")
     482(define-foreign-variable B200 speed_t "B200")
     483(define-foreign-variable B300 speed_t "B300")
     484(define-foreign-variable B600 speed_t "B600")
     485(define-foreign-variable B1200 speed_t "B1200")
     486(define-foreign-variable B1800 speed_t "B1800")
     487(define-foreign-variable B2400 speed_t "B2400")
     488(define-foreign-variable B4800 speed_t "B4800")
     489(define-foreign-variable B9600 speed_t "B9600")
     490(define-foreign-variable B19200 speed_t "B19200")
     491(define-foreign-variable B38400 speed_t "B38400")
     492(cond-expand
     493  [macosx
     494    (define-foreign-variable B7200 speed_t "B7200")
     495    (define-foreign-variable B14400 speed_t "B14400")
     496    (define-foreign-variable B28800 speed_t "B28800")
     497    (define-foreign-variable B57600 speed_t "B57600")
     498    (define-foreign-variable B76800 speed_t "B76800")
     499    (define-foreign-variable B115200 speed_t "B115200")
     500    (define-foreign-variable B230400 speed_t "B230400")
     501    (define-foreign-variable EXTA speed_t "EXTA")
     502    (define-foreign-variable EXTB speed_t "EXTB")
     503  ] [else] )
     504
     505#>
     506#define C_cfgetispeed( pt ) \
     507    C_fix( cfgetispeed( C_pointer_cast( pt, (struct termios) ) ) )
     508#define C_cfgetospeed( pt ) \
     509    C_fix( cfgetospeed( C_pointer_cast( pt, (struct termios) ) ) )
     510
     511#define C_cfsetispeed( pt, sp ) \
     512    C_fix( cfsetispeed( C_pointer_cast( pt, (struct termios) ), C_unfix( sp ) ) )
     513#define C_cfsetospeed( pt, sp ) \
     514    C_fix( cfsetospeed( C_pointer_cast( pt, (struct termios) ), C_unfix( sp ) ) )
     515<#
     516
     517(define (terminal-control-input-speed ptermios)
     518  (##sys#check-pointer ptermios 'terminal-control-input-speed)
     519
     520(define (terminal-control-output-speed ptermios)
     521  (##sys#check-pointer ptermios 'terminal-control-output-speed)
     522
     523(define (set-terminal-control-input-speed! ptermios speed)
     524  (##sys#check-pointer ptermios 'set-terminal-control-output-speed!)
     525  (##sys#check-exact speed 'set-terminal-control-input-speed!)
     526  (when (fx= -1 (##core#inline "C_cfsetispeed" ptermios speed))
     527    (##sys#posix-error #:file-error 'set-terminal-control-input-speed! "cannot change termios input speed" speed) ) )
     528
     529(define (set-terminal-control-output-speed! ptermios speed)
     530  (##sys#check-pointer ptermios 'set-terminal-control-output-speed!)
     531  (##sys#check-exact speed 'set-terminal-control-output-speed!)
     532  (when (fx= -1 (##core#inline "C_cfsetospeed" ptermios speed))
     533    (##sys#posix-error #:file-error 'set-terminal-control-output-speed! "cannot change termios output speed" speed) ) )
     534
     535(cond-expand
     536  [solaris
     537    #>
     538    static int
     539    cfsetspeed( struct termios * options, speed_t speed )
     540    {
     541        if (0 == cfsetispeed( options, speed ))
     542            return cfsetospeed( options, speed );
     543        else
     544            return -1;
     545    }
     546    <#
     547  ] [else] )
     548
     549#<
     550#define C_cfsetspeed( pt ) \
     551    C_fix( cfsetspeed( C_pointer_cast( pt, (struct termios) ), C_unfix( sp ) ) )
     552>#
     553
     554(define (set-terminal-control-speed! ptermios speed)
     555  (##sys#check-pointer ptermios 'set-terminal-control-speed!)
     556  (##sys#check-exact speed 'set-terminal-control-speed!)
     557  (when (fx= -1 (##core#inline "C_cfsetspeed" ptermios speed))
     558    (##sys#posix-error #:file-error 'set-terminal-control-speed! "cannot change termios speed" ptermios speed) ) )
     559
     560;; Terminal Control Get & Set
     561
     562bsd now drain flush soft
     563solaris linux now drain flush
     564
     565(define-foreign-variable TCSANOW int "TCSANOW")
     566(define-foreign-variable TCSADRAIN int "TCSADRAIN")
     567(define-foreign-variable TCSAFLUSH int "TCSAFLUSH")
     568
     569(cond-expand
     570  [(or macosx freebsd netbsd openbsd)
     571    (define-foreign-variable TCSASOFT int "TCSASOFT")
     572  ] [else] )
     573
     574#>
     575#define C_tcgetattr( fd, pt ) \
     576    C_fix( tcgetattr( C_unfix( fd ), C_pointer_cast( pt, (struct termios) ) ) )
     577#define C_tcsetattr( fd, act, pt ) \
     578    C_fix( tcsetattr( C_unfix( fd ), C_unfix( act ), C_pointer_cast( pt, (struct termios) ) ) )
     579<#
     580
     581(define (terminal-control-attributes fd #!optional ptermios)
     582  (##sys#check-exact fd 'terminal-control-attributes)
     583  (unless ptermios
     584    (set! ptermios (alloc-termios)) )
     585  (##sys#check-pointer ptermios 'terminal-control-attributes)
     586  (if (fx= -1 (##core#inline "C_tcgetattr" fd ptermios))
     587    (##sys#posix-error #:file-error 'terminal-control-attributes "cannot copy terminal parameters" fd)
     588     ptermios ) )
     589
     590(define (set-terminal-control-attributes! fd act ptermios)
     591  (##sys#check-exact fd 'set-terminal-control-attributes!)
     592  (##sys#check-exact act 'set-terminal-control-attributes!)
     593  (##sys#check-pointer ptermios 'set-terminal-control-attributes!)
     594  (when (fx= -1 (##core#inline "C_tcsetattr" fd act ptermios))
     595    (##sys#posix-error #:file-error 'set-terminal-control-attributes! "cannot change terminal parameters" fd act) ) )
     596
     597;; Terminal Control Drain
     598
     599#>
     600#define C_tcdrain( fd )  C_fix( tcdrain( C_unfix( fd ) ) )
     601<#
     602
     603(define (terminal-control-drain fd)
     604  (##sys#check-exact fd 'terminal-control-drain)
     605  (when (fx= -1 (##core#inline "C_tcdrain" fd))
     606    (##sys#posix-error #:file-error 'terminal-control-drain "cannot drain terminal input" fd) ) )
     607
     608;; Terminal Control Flow
     609
     610(define-foreign-variable TCOOFF int "TCOOFF")
     611(define-foreign-variable TCOON int "TCOON")
     612(define-foreign-variable TCIOFF int "TCIOFF")
     613(define-foreign-variable TCION int "TCION")
     614
     615#>
     616#define C_tcflow( fd, act )  C_fix( tcflow( C_unfix( fd ), C_unfix( act ) ) )
     617<#
     618
     619(define (terminal-control-flow fd act)
     620  (##sys#check-exact fd 'terminal-control-flow)
     621  (##sys#check-exact act 'terminal-control-flow)
     622  (when (fx= -1 (##core#inline "C_tcflow" fd act))
     623    (##sys#posix-error #:file-error 'terminal-control-flow "cannot control terminal flow" fd act) ) )
     624
     625;; Terminal Control Flush
     626
     627(define-foreign-variable TCIFLUSH int "TCIFLUSH")
     628(define-foreign-variable TCOFLUSH int "TCOFLUSH")
     629(define-foreign-variable TCIOFLUSH int "TCIOFLUSH")
     630
     631#>
     632#define C_tcflush( fd, act )  C_fix( tcflush( C_unfix( fd ), C_unfix( act ) ) )
     633<#
     634
     635(define (terminal-control-flush fd act)
     636  (##sys#check-exact fd 'terminal-control-flush)
     637  (##sys#check-exact act 'terminal-control-flush)
     638  (when (fx= -1 (##core#inline "C_tcflush" fd act))
     639    (##sys#posix-error #:file-error 'terminal-control-flush "cannot perform terminal flush" fd act) ) )
     640
     641;; Terminal Control Send Break
     642
     643#>
     644#define C_tcsendbreak( fd, dur )  C_fix( tcsendbreak( C_unfix( fd ), C_unfix( dur ) ) )
     645<#
     646
     647(define (terminal-control-send-break fd dur)
     648  (##sys#check-exact fd 'terminal-control-send-break)
     649  (##sys#check-exact dur 'terminal-control-send-break)
     650  (when (fx= -1 (##core#inline "C_tcsendbreak" fd dur))
     651    (##sys#posix-error #:file-error 'terminal-control-send-break "cannot transmit terminal break" fd dur) ) )
     652
     653(cond-expand
     654  [solaris
     655    #>
     656    static void
     657    cfmakeraw( struct termios * options )
     658    {
     659        options->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
     660        options->c_oflag &= ~OPOST;
     661        options->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
     662        options->c_cflag &= ~(CSIZE|PARENB);
     663        options->c_cflag |= CS8;
     664
     665        return 0;
     666    }
     667    <#
     668  ] [else] )
     669
     670#<
     671#define C_cfmakeraw( pt ) C_fix( cfmakeraw( C_pointer_cast( pt, (struct termios) ) ) )
     672>#
     673
     674(define (terminal-control-make-raw ptermios)
     675  (##sys#check-pointer ptermios 'terminal-control-make-raw)
     676  (if (fx= -1 (##core#inline "C_cfmakeraw" ptermios))
     677    (##sys#posix-error #:file-error 'terminal-control-make-raw "cannot set terminal raw I/O path" ptermios) ) )
    309678
    310679;;; Pseudo-tty
     
    328697        [solaris
    329698
    330                 (define-unimplemented openpty)
     699                (define-unimplemented open-pseudo-tty)
    331700                (define-unimplemented login-tty)
    332                 (define-unimplemented forkpty)
     701                (define-unimplemented fork-pseudo-tty)
    333702
    334703        ] [else
     
    341710                #else
    342711                # include <pty.h>
     712                # include <utmp.h>
    343713                #endif
     714
     715    #define C_openpty( pm, ps, pn, pt, pw ) \
     716        C_fix( openpty( C_locative_cast( pm, int ), C_locative_cast( ps, int ), \
     717                        C_pointer_cast( pn, char ), \
     718                        C_pointer_cast( pt, (struct termios) ), \
     719                        C_pointer_cast( pw, (struct winsize) ) ) )
     720
     721    #define C_login_tty( fd )   C_fix( login_tty( C_unfix( fd ) ) )
     722
     723    #define C_forkpty( pm, pn, pt, pw ) \
     724        C_fix( forkpty( C_locative_cast( pm, int ), \
     725                        C_pointer_cast( pn, char ), \
     726                        C_pointer_cast( pt, (struct termios) ), \
     727                        C_pointer_cast( pw, (struct winsize) ) ) )
    344728                <#
    345729
    346                 (define (openpty #!optional ptermios pwinsize)
    347       #;(check-pointer-or-false ptermios)
    348       #;(check-pointer-or-false pwinsize)
     730                (define (open-pseudo-tty #!optional ptermios pwinsize)
     731      (##sys#check-pointer-argument ptermios 'open-pseudo-tty)
     732      (##sys#check-pointer-argument pwinsize 'open-pseudo-tty)
    349733      (let-location ([master int]
    350734                     [slave int])
    351735                    (if (fx= 0 (##core#inline "C_openpty" #$master #$slave _null (or ptermios _null) (or pwinsize _null)))
    352736                      (values master slave)
    353                       (##sys#posix-error #:file-error 'openpty "cannot open pseudo-tty") ) ) )
     737                      (##sys#posix-error #:file-error 'open-pseudo-tty "cannot open pseudo-tty") ) ) )
    354738
    355739    (define (login-tty fd)
    356740      (##sys#check-exact fd 'login-tty)
    357                         (unless (fx= 0 (##core#inline "C_login_tty" fd))
     741                        (when (fx= -1 (##core#inline "C_login_tty" fd))
    358742                          (##sys#posix-error #:file-error 'login-tty "cannot login tty device" fd) ) )
    359743
    360     (define (forkpty thunk #!optional ptermios pwinsize)
    361       #;(check-pointer-or-false ptermios)
    362       #;(check-pointer-or-false pwinsize)
     744    (define (fork-pseudo-tty thunk #!optional ptermios pwinsize)
     745      (##sys#check-closure thunk 'fork-pseudo-tty)
     746      (##sys#check-pointer-argument ptermios 'fork-pseudo-tty)
     747      (##sys#check-pointer-argument pwinsize 'fork-pseudo-tty)
    363748      (let-location ([master int])
    364749        (let ([ret (##core#inline "C_forkpty" #$master _null (or ptermios _null) (or pwinsize _null))])
    365         (cond
    366           [(fx= -1 ret)
    367             (##sys#posix-error #:file-error 'forkpty "cannot create child process in pseudo-tty") ]
    368           [(fx= 0 ret)
    369             (thunk)
    370             ((foreign-lambda void "_exit" int) 0) ]
    371           [else
    372             (values ret master) ] ) ) ) )
    373 
    374         ] [else
     750          (cond
     751            [(fx= -1 ret)
     752              (##sys#posix-error #:file-error 'fork-pseudo-tty "cannot create child process in pseudo-tty") ]
     753            [(fx= 0 ret)
     754              (thunk)
     755              ((foreign-lambda void "_exit" int) 0) ]
     756            [else
     757              (values ret master) ] ) ) ) )
     758
    375759        ] )
    376760
     
    391775<#
    392776
    393 (define (isatty fd)
    394   (##sys#check-exact fd 'isatty)
     777(define (terminal-type-device? fd)
     778  (##sys#check-exact fd 'terminal-type-device?)
    395779  (##core#inline "C_isatty" fd) )
    396780
    397781(define-constant _devicename_max int 255) ; probably too generous
    398782
    399 (define ttyname
     783#;
     784(define terminal-device-name
    400785  (let ([string-length string-length]
    401786        [defbuf (##sys#make-string (fx+ _devicename_max 1))] )
    402787    (lambda (fd #!optional (buf defbuf))
    403       (##sys#check-exact fd 'ttyname)
     788      (##sys#check-exact fd 'terminal-device-name)
    404789      (let ([buflen (if (eq? buf defbuf) _devicename_max (fx- (string-length buf) 1))])
    405790        (let ([len (##core#inline "C_ttyname" fd buf buflen)])
    406791          (cond
    407792            [(not len)
    408               (##sys#signal-hook #:limit-error 'ttyname "buffer overflow" fd) ]
     793              (##sys#signal-hook #:limit-error 'terminal-device-name "buffer overflow" fd) ]
    409794            [(fx= 0 len)
    410795              ; Cannot find device or not a tty.
     
    413798              (##sys#substring buf 0 len) ] ) ) ) ) ) )
    414799
    415 (define (ttyslot)
     800(define terminal-device-name
     801  (let ([defbuf (##sys#make-string (fx+ _devicename_max 1))] )
     802    (lambda (fd)
     803      (##sys#check-exact fd 'terminal-device-name)
     804      (let ([len (##core#inline "C_ttyname" fd defbuf _devicename_max)])
     805        (cond
     806          [(not len)
     807            (##sys#signal-hook #:limit-error 'terminal-device-name "buffer overflow" fd) ]
     808          [(fx= 0 len)
     809            ; Cannot find device or not a tty.
     810            #f ]
     811          [else
     812            (##sys#substring buf 0 len) ] ) ) ) ) )
     813
     814(define (current-process-tty-number)
    416815  (let ([fd (##core#inline "C_ttyslot")])
    417816    (if (fx= 0 fd)
    418       (##sys#posix-error #:file-error 'ttyslot "cannot fetch current process control terminal number")
     817      (##sys#posix-error #:file-error 'current-process-tty-number "cannot fetch current process control terminal number")
    419818      fd ) ) )
    420819
  • release/3/posix-extensions/trunk/posix-extensions.wiki

    r13079 r13118  
    2020
    2121Processes are identified by two values, {{WHICH}} and {{WHO}}. The value of
    22 {{WHICH}} defines how {{WHO}} is interpreted. The {{WHICH}} values are:
    23 
    24 <constant>priority/process</constant>
     22{{WHICH}} defines how {{WHO}} is interpreted.
     23
     24The {{WHICH}} values are:
     25
     26<constant>prio/process</constant>
    2527
    2628{{WHO}} is a process ID, or {{0}} to refer to the current process.
    2729
    28 <constant>priority/process-group</constant>
     30<constant>prio/process-group</constant>
    2931
    3032{{WHO}} is a process group ID, or {{0}} to refer to the current process group.
    3133
    32 <constant>priority/user</constant>
     34<constant>prio/user</constant>
    3335
    3436{{WHO}} is a user ID, or {{0}} to refer to the current user.
     37
     38MacOS X Specific:
     39
     40<constant>prio/darwin-thread</constant>
     41
     42{{WHO}} is {{0}} for the current thread.
    3543
    3644<procedure>(scheduling-priority WHICH WHO)</procedure>
     
    4351an integer between {{-20}} and {{20}} inclusive.
    4452
     53MacOS X Specific:
     54
     55<constant>prio/darwin-bg</constant>
     56
     57When {{WHICH}} is {{prio/darwin-thread}} then the {{PRIORITY}} must be
     58{{0}} or {{prio/darwin-bg}}.
     59
    4560Unavailable with Windows.
    4661
    4762=== Pseudo-TTYs
    4863
    49 <procedure>(login-tty SLAVE-FILENO)</procedure>
    50 
    51 As per the C function {{login_tty(3)}}, prepares the pty slave for use.
    52 
    53 <procedure>(open-pty MASTER-FILENO SLAVE-FILENO NAME WINSIZE TERMIOS)</procedure>
    54 
    55 As per the C function {{open_pty(3)}}, creates a new pty, and assigns the master
    56 and slave fds into {{MASTER-FILENO}} and {{SLAVE-FILENO}} (which must be
    57 pointers to fds).
    58 
    59 {{NAME}} is a {{c-string}} which, in practice, should be {{#f}} (NULL) since
    60 memory overflow is possible should the name be longer than the allocated
    61 string.
    62 
    63 {{WINSIZE}} and {{TERMIOS}} are c-pointers to the respective structures, see below.
    64 
    65 <procedure>(forkpty MASTER-FILENO NAME WINSIZE TERMIOS) => INT</procedure>
    66 
    67 As per the C function {{forkpty(3)}}, creates a new pty, and assigns the master
    68 fds into {{MASTER-FILENO}} (which must be a pointer to a fd). Returns the
    69 process-id of the created process.
    70 
    71 {{NAME}}, {{WINSIZE}}, and {{TERMIOS}} as in {{open_pty}}.
     64<procedure>(login-tty FILENO)</procedure>
     65
     66As per the C function {{login_tty(3)}}, prepares the tty for use.
     67
     68{{FILENO}} is usually the slave-fileno of a pseudo-tty but can be an real open
     69tty device.
     70
     71<procedure>(open-pseudo-tty [WINSIZE [TERMIOS]]) => (values MASTER-FILENO SLAVE-FILENO)</procedure>
     72
     73As per the C function {{openpty(3)}}, creates a new pty, and returns the master
     74and slave fds {{MASTER-FILENO}} and {{SLAVE-FILENO}}.
     75
     76{{WINSIZE}} and {{TERMIOS}} are {{pointers}}, or {{#f}}, to the respective structures, see below.
     77
     78The pseudo-tty name must be retrieved using the {{terminal-device-name}}
     79procedure. A non-null {{name}} argument of the {{openpty}} system call can
     80result in buffer overflow.
     81
     82<procedure>(fork-pseudo-tty THUNK [WINSIZE [TERMIOS]]) => (values PID_T MASTER-FILENO)</procedure>
     83
     84As per the C function {{forkpty(3)}}, creates a new pty, and returns the master
     85fd {{MASTER-FILENO}} and process-id of the created process.
     86
     87The pseudo-tty name, {{WINSIZE}}, and {{TERMIOS}} as in {{open_pty}}.
    7288
    7389Unavailable with Windows.
     
    8399Releases a C struct winsize.
    84100
     101<procedure>(make-winsize [#:rows COUNT] [#:columns COUNT] [#:xpixels COUNT] [#:ypixels COUNT]) => WINSIZE</procedure>
     102
     103Returns the pointer to a new C {{struct winsize}}, initialized per supplied arguments.
     104
     105Sets a finalizer.
     106
    85107Winsize has the following accessors:
    86108
    87 <procedure>(winsize-col WINSIZE) => WS_COL</procedure>
    88 <procedure>(winsize-col-set! WINSIZE WS_COL)</procedure>
    89 
    90 <procedure>(winsize-row WINSIZE) => WS_ROW</procedure>
    91 <procedure>(winsize-row-set! WINSIZE WS_ROW)</procedure>
    92 
    93 <procedure>(winsize-xpixel WINSIZE) => WS_XPIXEL</procedure>
    94 <procedure>(winsize-xpixel-set! WINSIZE WS_XPIXEL)</procedure>
    95 
    96 <procedure>(winsize-ypixel WINSIZE) => WS_YPIXEL</procedure>
    97 <procedure>(winsize-ypixel-set! WINSIZE WS_YPIXEL)</procedure>
     109<procedure>(winsize-col WINSIZE) => INTEGER</procedure>
     110<procedure>(winsize-col-set! WINSIZE INTEGER)</procedure>
     111
     112<procedure>(winsize-row WINSIZE) => INTEGER</procedure>
     113<procedure>(winsize-row-set! WINSIZE INTEGER)</procedure>
     114
     115<procedure>(winsize-xpixel WINSIZE) => INTEGER</procedure>
     116<procedure>(winsize-xpixel-set! WINSIZE INTEGER)</procedure>
     117
     118<procedure>(winsize-ypixel WINSIZE) => INTEGER</procedure>
     119<procedure>(winsize-ypixel-set! WINSIZE INTEGER)</procedure>
     120
     121The domain of all {{INTEGER}} is {{unsigned short}}.
    98122
    99123Unavailable with Windows.
     
    109133Releases a C {{struct termios}}.
    110134
     135<procedure>(make-termios [#:iflags TCFLAG_T] [#:oflags TCFLAG_T] [#:cflags TCFLAG_T] [#:lflags TCFLAG_T] [#:cc LIST | VECTOR | STRING]) => TERMIOS</procedure>
     136
     137Returns the pointer to a new C {{struct termios}}, initialized per supplied arguments.
     138
     139Sets a finalizer.
     140
    111141Termios has the following accessors:
    112142
    113 <procedure>(termios-cc TERMIOS IDX) => C_CC</procedure>
    114 <procedure>(termios-cc-set! TERMIOS IDX C_CC)</procedure>
    115 
    116 <procedure>(termios-cflag TERMIOS) => C_CFLAG</procedure>
    117 <procedure>(termios-cflag-set! TERMIOS C_CFLAG)</procedure>
    118 
    119 <procedure>(termios-iflag TERMIOS) => C_IFLAG</procedure>
    120 <procedure>(termios-iflag-set! TERMIOS C_IFLAG)</procedure>
    121 
    122 <procedure>(termios-lflag TERMIOS) => C_LFLAG</procedure>
    123 <procedure>(termios-lflag-set! TERMIOS C_LFLAG)</procedure>
    124 
    125 <procedure>(termios-oflag TERMIOS) => C_OFLAG</procedure>
    126 <procedure>(termios-oflag-set! TERMIOS C_OFLAG)</procedure>
    127 
    128 <procedure>(termios-ispeed TERMIOS) => C_ISPEED</procedure>
    129 <procedure>(termios-ispeed-set! TERMIOS C_ISPEED)</procedure>
    130 
    131 <procedure>(termios-ospeed TERMIOS) => C_OSPEED</procedure>
    132 <procedure>(termios-ospeed-set! TERMIOS C_OSPEED)</procedure>
    133 
    134 Unavailable with Windows.
     143<procedure>(termios-cc TERMIOS IDX) => CC_T</procedure>
     144<procedure>(termios-cc-set! TERMIOS IDX CC_T)</procedure>
     145
     146<procedure>(termios-cflag TERMIOS) => TCFLAG_T</procedure>
     147<procedure>(termios-cflag-set! TERMIOS TCFLAG_T)</procedure>
     148
     149<procedure>(termios-iflag TERMIOS) => TCFLAG_T</procedure>
     150<procedure>(termios-iflag-set! TERMIOS TCFLAG_T)</procedure>
     151
     152<procedure>(termios-lflag TERMIOS) => TCFLAG_T</procedure>
     153<procedure>(termios-lflag-set! TERMIOS TCFLAG_T)</procedure>
     154
     155<procedure>(termios-oflag TERMIOS) => TCFLAG_T</procedure>
     156<procedure>(termios-oflag-set! TERMIOS TCFLAG_T)</procedure>
     157
     158Unavailable with Windows.
     159
     160===
     161
     162{{SPEED}}
     163
     164{{TERMIOS}} is a {{(c-pointer struct termios)}}.
     165
     166{{FILENO}}
     167
     168<procedure>(terminal-control-input-speed TERMIOS) => SPEED</procedure>
     169<procedure>(terminal-control-output-speed TERMIOS) => SPEED</procedure>
     170<procedure>(set-terminal-control-input-speed! TERMIOS SPEED)</procedure>
     171<procedure>(set-terminal-control-output-speed! TERMIOS SPEED)</procedure>
     172
     173Get & set input & output speed elements of the {{TERMIOS}}, respectively.
     174
     175<procedure>(set-terminal-control-speed! TERMIOS SPEED)</procedure>
     176
     177Set both input & output speed elements of the {{TERMIOS}}.
     178
     179<procedure>(terminal-control-attributes FILENO [TERMIOS]) => TERMIOS</procedure>
     180<procedure>(set-terminal-control-attributes! FILENO ACTION TERMIOS)</procedure>
     181
     182Get & set the {{TERMIOS}} elements.
     183
     184<procedure>(terminal-control-drain FILENO)</procedure>
     185
     186<procedure>(terminal-control-flow FILENO ACTION)</procedure>
     187
     188<procedure>(terminal-control-flush FILENO ACTION)</procedure>
     189
     190<procedure>(terminal-control-send-break FILENO DURATION)</procedure>
     191
     192<procedure>(terminal-control-make-raw TERMIOS)</procedure>
    135193
    136194==== Terminal Information
    137195
    138 <procedure>(isatty FILENO) => BOOLEAN</procedure>
     196<procedure>(terminal-type-device? FILENO) => BOOLEAN</procedure>
    139197
    140198Does the file descriptor {{FILENO}} refer to a valid terminal type device?
     
    142200The {{isatty(3)}} system call.
    143201
    144 <procedure>(ttyname FILENO) => STRING</procedure>
     202<procedure>(terminal-device-name FILENO) => STRING</procedure>
    145203
    146204Returns the related device name for the file descriptor {{FILENO}}, or {{#f}}
     
    149207The {{ttyname(3)}} system call.
    150208
    151 <procedure>(ttyslot) => INT</procedure>
     209<procedure>(current-process-tty-number) => INTEGER</procedure>
    152210
    153211Returns the current process' control terminal number, or {{0}} if there isn't one.
Note: See TracChangeset for help on using the changeset viewer.