Skip to content

macOS TIOCGETA/TIOCSETA are missing #4735

@mmastrac

Description

@mmastrac

Target triples

aarch64-apple-darwin
x86_64-apple-darwin

(*-apple-*, in fact)

Documentation

TIOCGETA/TIOCSETA are missing in Apple's libc implementation in this crate, but are present in the various OS headers.

TIOCGETA  = 0x40487413
TIOCSETA  = 0x80487414
TIOCSETAW = 0x80487415
TIOCSETAF = 0x80487416

From man tty 4:

     TIOCGETA struct termios *term
                 Place the current value of the termios state associated with the device in the termios structure pointed to by term.  This is the underlying call that
                 implements the termios(4) tcgetattr() call.

     TIOCSETA struct termios *term
                 Set the termios state associated with the device immediately.  This is the underlying call that implements the termios(4) tcsetattr() call with the TCSANOW
                 option.

Header values:

#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/ttycom.h>   // TIOCGETA/TIOCSETA
#include <termios.h>      // struct termios

int main(void) {
    printf("TIOCGETA  = 0x%lx\n", (unsigned long)TIOCGETA);
    printf("TIOCSETA  = 0x%lx\n", (unsigned long)TIOCSETA);
    printf("TIOCSETAW = 0x%lx\n", (unsigned long)TIOCSETAW);
    printf("TIOCSETAF = 0x%lx\n", (unsigned long)TIOCSETAF);
    return 0;
}

/*
TIOCGETA  = 0x40487413
TIOCSETA  = 0x80487414
TIOCSETAW = 0x80487415
TIOCSETAF = 0x80487416
*/

From bsd/sys/ttycom.h:

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/ttycom.h:108:#define TIOCGETA        _IOR('t', 19, struct termios) /* get termios struct */
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/ttycom.h:109:#define TIOCSETA        _IOW('t', 20, struct termios) /* set termios struct */
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/ttycom.h:110:#define TIOCSETAW       _IOW('t', 21, struct termios) /* drain output, set */
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/ttycom.h:111:#define TIOCSETAF       _IOW('t', 22, struct termios) /* drn out, fls in, set */

Go's implementation (2nd source):

	TIOCGETA                          = 0x40487413
// ...
	TIOCSETA                          = 0x80487414

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions