I compiled the following program on a riscv64 Ubuntu 26.04 system as
static binary

#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <linux/tty.h>

int main(int argc, char *argv[]) {
    if (argc != 2) {
        fprintf(stderr, "Usage: %s <device>\n", argv[0]);
        return 1;
    }

    // Open the specified device
    int fd = open(argv[1], O_RDONLY);
    if (fd < 0) {
        perror("Failed to open device");
        return 1;
    }

    // Use ioctl to check if the device is a TTY
    struct winsize w;
    if (ioctl(fd, TIOCGWINSZ, &w) == -1) {
        // If ioctl fails, it's not a tty
        perror("Not a terminal (tty) or error occurred");
    } else {
        // If ioctl succeeds, it's a tty
        printf("%s is a terminal (tty).\n", argv[1]);
    }

    // Close the device
    close(fd);
    return 0;
}

I then transferred it to the Ubuntu 26.10 container and executed it:

/tmp/check_tty /dev/pts/0
/dev/pts/0 is a terminal (tty)

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2133188

Title:
  Illegal instruction in memset under qemu-user for riscv64

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/2133188/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to