Changeset 13079 in project


Ignore:
Timestamp:
01/24/09 19:25:05 (11 years ago)
Author:
Kon Lovett
Message:

Added more tty support.

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

Legend:

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

    r13039 r13079  
    1212;; This can be done better - actually check for the field's existence in the
    1313;; .setup w/ a 'try-compile' & then pass info as a '-feature SYMBOL'.
     14;;
     15;; - Should have a 'pid_t' type, even though Unix posix doesn't.
    1416
    1517(declare
     
    7577    open-pty
    7678    login-tty
     79    forkpty
     80    ;
     81                isatty
     82                ttyname
     83                ttyslot
    7784    ;
    7885    replace-fileno ) )
     
    415422                (define-unimplemented open-pty)
    416423                (define-unimplemented login-tty)
     424                (define-unimplemented forkpty)
    417425
    418426        ] [else
     
    432440                                                                                                                                                c-string c-pointer c-pointer))
    433441
     442                (define forkpty
     443                        (foreign-lambda int "forkpty" (nonnull-c-pointer int) c-string c-pointer c-pointer))
     444
    434445                (define login-tty
    435446                        (foreign-lambda int "login_tty" int))
     447
     448        ] [else
     449        ] )
     450
     451;; Terminal Information
     452
     453(cond-expand
     454        [solaris
     455
     456                (define-unimplemented isatty)
     457                (define-unimplemented ttyname)
     458                (define-unimplemented ttyslot)
     459
     460        ] [else
     461
     462    #>
     463    #include <unistd.h>
     464    <#
     465   
     466    (define isatty (foreign-lambda bool "isatty" int))
     467   
     468    (define ttyname (foreign-lambda c-string "ttyname" int))
     469   
     470    (define ttyslot (foreign-lambda int "ttyslot"))
    436471
    437472        ] [else
  • release/3/posix-extensions/trunk/4windows.scm

    r13039 r13079  
    7070    open-pty
    7171    login-tty
     72    forkpty
     73    ;
     74                isatty
     75                ttyname
     76                ttyslot
    7277    ;
    7378    replace-fileno ) )
     
    159164(define-unimplemented open-pty)
    160165(define-unimplemented login-tty)
     166(define-unimplemented forkpty)
     167
     168;; Terminal Information
     169
     170(define-unimplemented isatty)
     171(define-unimplemented ttyname)
     172(define-unimplemented ttyslot)
    161173
    162174;;
  • release/3/posix-extensions/trunk/posix-extensions.wiki

    r13078 r13079  
    4343an integer between {{-20}} and {{20}} inclusive.
    4444
     45Unavailable with Windows.
     46
    4547=== Pseudo-TTYs
    4648
    47 This is currently a thin wrapper around the C interface. Scheme bindings for
    48 the necessary C constants are not yet provided.
    49 
    5049<procedure>(login-tty SLAVE-FILENO)</procedure>
    5150
    52 As per the C function {{login_tty}}, prepares the pty slave for use.
     51As per the C function {{login_tty(3)}}, prepares the pty slave for use.
    5352
    5453<procedure>(open-pty MASTER-FILENO SLAVE-FILENO NAME WINSIZE TERMIOS)</procedure>
    5554
    56 As per the C function {{open_pty}}, creates a new pty, and assigns the master
    57 and slave fds into {{MASTER-FILENO}} and {{SLAVE-FILENO}} (which should be
     55As per the C function {{open_pty(3)}}, creates a new pty, and assigns the master
     56and slave fds into {{MASTER-FILENO}} and {{SLAVE-FILENO}} (which must be
    5857pointers to fds).
    5958
     59{{NAME}} is a {{c-string}} which, in practice, should be {{#f}} (NULL) since
     60memory overflow is possible should the name be longer than the allocated
     61string.
     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
     67As per the C function {{forkpty(3)}}, creates a new pty, and assigns the master
     68fds into {{MASTER-FILENO}} (which must be a pointer to a fd). Returns the
     69process-id of the created process.
     70
     71{{NAME}}, {{WINSIZE}}, and {{TERMIOS}} as in {{open_pty}}.
     72
     73Unavailable with Windows.
     74
    6075==== Window size
    6176
     
    6883Releases a C struct winsize.
    6984
    70 Winsizes have the following accessors:
     85Winsize has the following accessors:
    7186
    7287<procedure>(winsize-col WINSIZE) => WS_COL</procedure>
     
    8297<procedure>(winsize-ypixel-set! WINSIZE WS_YPIXEL)</procedure>
    8398
     99Unavailable with Windows.
     100
    84101==== Termios
    85102
     
    92109Releases a C {{struct termios}}.
    93110
    94 Termioses have the following accessors:
     111Termios has the following accessors:
    95112
    96113<procedure>(termios-cc TERMIOS IDX) => C_CC</procedure>
     
    115132<procedure>(termios-ospeed-set! TERMIOS C_OSPEED)</procedure>
    116133
     134Unavailable with Windows.
     135
     136==== Terminal Information
     137
     138<procedure>(isatty FILENO) => BOOLEAN</procedure>
     139
     140Does the file descriptor {{FILENO}} refer to a valid terminal type device?
     141
     142The {{isatty(3)}} system call.
     143
     144<procedure>(ttyname FILENO) => STRING</procedure>
     145
     146Returns the related device name for the file descriptor {{FILENO}}, or {{#f}}
     147if not a tty device.
     148
     149The {{ttyname(3)}} system call.
     150
     151<procedure>(ttyslot) => INT</procedure>
     152
     153Returns the current process' control terminal number, or {{0}} if there isn't one.
     154
     155The {{ttyslot(3)}} system call.
     156
     157Unavailable with Windows.
     158
    117159==== Stat object types
    118160
    119 The posix unit declares constants for file modes, but the mode returned by
     161The [[Unit posix]] declares constants for file modes, but the mode returned by
    120162{{file-stat}} also includes higher-order bits for the type of object. See the
    121163manpage for {{stat(2)}} for details.
     
    130172<constant>stat/ifsock</constant>
    131173
     174Unavailable with Windows.
     175
    132176==== File metadata
    133177
    134178<procedure>(change-link-mode FILENAME MODE)</procedure>
    135179
    136 As per {{change-file-mode}} in [[Unix posix]], but if used on a symlink,
     180As per {{change-file-mode}} in [[Unit posix]], but if used on a symlink,
    137181operates upon the link itself rather than on the object linked to.
    138182
    139183<procedure>(change-link-owner FILENAME UID GID)</procedure>
    140184
    141 As per {{change-file-owner}} in [[Unix posix]], but if used on a symlink,
     185As per {{change-file-owner}} in [[Unit posix]], but if used on a symlink,
    142186operates upon the link itself rather than on the object linked to.
    143187
     
    150194Sets the atime and mtime of a file using the {{utime(2)}} system call.
    151195
     196Unavailable with Windows.
    152197
    153198== Examples
     
    162207== Author
    163208
    164 [[kon lovett]]
     209[[kon lovett|Kon Lovett]]
    165210[[alaric-blagrave-snellpym|Alaric Snell-Pym]]
    166211
Note: See TracChangeset for help on using the changeset viewer.