1

This is really just to satisfy my curiosity after this question. Although I'm now using an alternative solution, the original problem appears to come down to the fact that TIOCMGET is not implemented, and I'd like to know a bit about why that is.

Sadly, I haven't found much useful information just by googling, and I'm finding the tty_ioctl man page (the first result) pretty impenetrable.

So, what exactly is TIOCMGET, where is it implemented, and where might mono be looking for it and failing to find it?

4

1 回答 1

3

It's implemented in drivers/tty/tty_io.c which has the following implementation:

/**
 *      tty_tiocmget            -       get modem status
 *      @tty: tty device
 *      @file: user file pointer
 *      @p: pointer to result
 *
 *      Obtain the modem status bits from the tty driver if the feature
 *      is supported. Return -EINVAL if it is not available.
 *
 *      Locking: none (up to the driver)
 */

static int tty_tiocmget(struct tty_struct *tty, int __user *p)
{
        int retval = -EINVAL;

        if (tty->ops->tiocmget) {
                retval = tty->ops->tiocmget(tty);

                if (retval >= 0)
                        retval = put_user(retval, p);
        }
        return retval;
}

As you will note from the comment, and the code, it only works if the underlying terminal driver supports it and will otherwise return EINVAL.

There are a number of drivers which do support it, such as isdn4linux and various GSM modem drivers, but ordinary terminals won't do as they are not modems.

于 2013-02-12T10:59:09.557 回答