Section 20.4. Finding the Current VC

   


20.4. Finding the Current VC

To find the number of the current VC, use the VT_GETSTATE ioctl, which takes a pointer to a struct vt_stat and returns the number of the current VC in the v_active element:

 unsigned short get_current_vc(int fd) {     struct vt_stat vs;     ioctl(fd, VT_GETSTATE, &vs);     return (vs.v_active); } 


To locate the correct device entry for the current VC, use

 sprintf(ttyname, "/dev/tty%d", get_current_vc(fd)); 



       
    top
     


    Linux Application Development
    Linux Application Development (paperback) (2nd Edition)
    ISBN: 0321563220
    EAN: 2147483647
    Year: 2003
    Pages: 168

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net