Chapter Contents

Previous

Next
uname

uname



Display Current Operating System Name

Portability: POSIX.1 conforming, UNIX compatible


SYNOPSIS
DESCRIPTION
RETURN VALUE
EXAMPLE
RELATED FUNCTIONS


SYNOPSIS

#include <sys/utsname.h>

int uname(struct utsname *sysInfo);


DESCRIPTION

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;
points to the name of the operating system implementation.

char *nodename;
points to the node name within a communications network for the specific implementation.

char *release;
points to the current release level for the implementation.

char *version;
points to the current version number for the release.

char *machine;
points to the name of the machine on which the operating system is running.


RETURN VALUE

uname returns a nonnegative value if successful and a -1 if unsuccessful.


EXAMPLE

The following example illustrates the use of uname to determine information about the operating system:

#include <systypes.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");
}


RELATED FUNCTIONS

sysname , syslevel


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.