Standards / Extensions | C or C++ | Dependencies |
---|---|---|
POSIX.1 |
both |
#define _POSIX_SOURCE
#include <sys/utsname.h>
int uname(struct utsname *name);
The uname() function retrieves information identifying the operating system you are running on. The argument name points to a memory area where a structure describing the operating system the process is running on can be stored.
Each of the utsname structure elements is a normal C string, terminated with a NULL character.
As of OS/390® Release 2, the uname() function will return "OS/390" as the sysname value, even if the true name of the operating system is different. This is for compatibility purposes. The version value will increase at every new version of the operating system. The release value will increase at every new release of the operating system.
Table 1 lists the operating system names and corresponding values returned by the uname() function. To retrieve the true operating system name, version, and release, use the __osname() function.
Operating system | Sysname | Release | Version |
---|---|---|---|
z/OS® V2.1 | OS/390 | 24.00 | 04 |
z/OS V1.13 | OS/390 | 23.00 | 03 |
z/OS V1.12 | OS/390 | 22.00 | 03 |
z/OS V1.11 | OS/390 | 21.00 | 03 |
z/OS V1.10 | OS/390 | 20.00 | 03 |
z/OS V1.9 | OS/390 | 19.00 | 03 |
z/OS V1.8 | OS/390 | 18.00 | 03 |
z/OS V1.7 | OS/390 | 17.00 | 03 |
z/OS V1.6 | OS/390 | 16.00 | 03 |
z/OS V1.5 | OS/390 | 15.00 | 03 |
z/OS V1.4 | OS/390 | 14.00 | 03 |
z/OS V1.3 | OS/390 | 13.00 | 03 |
z/OS V1.2 | OS/390 | 12.00 | 03 |
z/OS V1.1 | OS/390 | 11.00 | 03 |
OS/390 V2.10 | OS/390 | 10.00 | 02 |
OS/390 V2.9 | OS/390 | 09.00 | 02 |
OS/390 V2.8 | OS/390 | 08.00 | 02 |
OS/390 V2.7 | OS/390 | 07.00 | 02 |
OS/390 V2.6 | OS/390 | 06.00 | 02 |
OS/390 V2.5 | OS/390 | 05.00 | 02 |
OS/390 V2.4 | OS/390 | 04.00 | 02 |
OS/390 V1.3 | OS/390 | 03.00 | 01 |
OS/390 V1.2 | OS/390 | 02.00 | 01 |
OS/390 V1.1 | MVS | 100 | 1 |
MVS | 2.2 | 5 |
If successful, the uname() function returns a nonnegative value.
If unsuccessful, the uname() function returns -1. An errno might be set to indicate the reason for the failure, but no errno values are specified by the POSIX.1 standard.
⁄* CELEBU03
This example gets information about the system you are running on.
*⁄
#define _POSIX_SOURCE
#include <sys⁄utsname.h>
#include <stdio.h>
main() {
struct utsname uts;
if (uname(&uts) < 0)
perror("uname() error");
else {
printf("Sysname: %s\n", uts.sysname);
printf("Nodename: %s\n", uts.nodename);
printf("Release: %s\n", uts.release);
printf("Version: %s\n", uts.version);
printf("Machine: %s\n", uts.machine);
}
}
Sysname: OS/390
Nodename: SY1
Release: 24.00
Version: 04
Machine: 2097