Getting minor device number from tty_nr attribute in /proc/pid/stat


I am trying to extract the minor device number from the tty_nr attribute in /proc/pid/stat. According to the documentation it is said that, minor device number is a combination 0-7 and 20-30 bits in tty_nr. How can I extract these bits from the tty_nr number?


There are macros already defined for this purpose. Use the MAJOR() and MINOR() macros that are defined in linux/kdev_t.h.

Answered By – z242

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published