lkml.org 
[lkml]   [1997]   [Mar]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Kernel version
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.


\
 
 \ /
  Last update: 2005-03-22 13:39    [W:0.040 / U:0.456 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site