Find RedHat version.

How can I find out with a C program, on which RedHat version the program is being ran ? I do know through compilation variables that I'm on RedHat but so far cannot find out which one.

Currently the closest I got was to invoke an ls or cat through syscall for the release or motd files.

Thanks:
Amir

uname is the classic API for this kind of thing.

It depends what you really want to find out, especially the version of what exactly, and what is that going to tell you.

you can get the full version from /etc/issue. I don't know of any more direct way of getting the RedHat version. Most system methods will give you the kernel version.

You have to remember that RedHat is just the distribution. All the system stuff is related to the kernel and the architecture. System calls will be designed with this in mind.

You can also supposedly get the info from /proc/version, but I've never seen that match the actual distro version number, so that might be a red herring.

/etc/redhat-release

Thanks to all who tried to help,

Basically I need to find out whether the program is running under RedHat 2.1 3.0 or 4.0 . This information is not available in uname. Parsing the information from the release or motd file is something I wanted to avoid.

If the program was running under a Debian release, what would you infer from that?