#include <sys/utsname.h> int uname(struct utsname *sysInfo);
uname
stores information about the operating system
you are running under in a structure at the location pointed
to by sysInfo
. The utsname
structure is declared
in <sys/utsname.h>
and has the following elements:
char *sysname;
char *nodename;
char *release;
char *version;
char *machine;
uname
returns a nonnegative value if successful and
a -1
if unsuccessful.
uname
to
determine information about the operating system:
#include <sys/types.h> #include <sys/utsname.h> #include <stdio.h> main() { struct utsname sysInfo; if (uname(&sysInfo) != -1) { puts(sysInfo.sysname); puts(sysInfo.nodename); puts(sysInfo.release); puts(sysInfo.version); puts(sysInfo.machine); } else perror("uname() error"); }
sysname
, syslevel
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.