Re: Kernel version

Samuli Kaski (samkaski@cs.Helsinki.FI)
Wed, 26 Mar 1997 09:43:23 +0200 (EET)


On Tue, 25 Mar 1997, Tomás Restrepo wrote:

> Can someone tell me if there is an easy way to get the kernel release and
> the nodename from within a C program?
>
> I know that in include/utsname.h there's an structure used for that, but I
> really don't know how to get to it.
>
> I'd appreciated if someone could help me out.

#include <stdio.h>
#include <stdlib.h>
#include <sys/utsname.h>

int main(int argc, char *argv[])
{
struct utsname un;

if(uname(&un) < 0) {
perror(argv[0]);

exit(EXIT_FAILURE);
}

printf("This is %s, running Linux %s\n", un.nodename, un.release);

exit(EXIT_SUCCESS);
}

--
Samuli Kaski, samkaski@cs.Helsinki.FI
Department of Computer Science, University of Helsinki, Finland.