-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patht_uname.c
36 lines (31 loc) · 1.21 KB
/
t_uname.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*************************************************************************\
* Copyright (C) Michael Kerrisk, 2024. *
* *
* This program is free software. You may use, modify, and redistribute it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation, either version 3 or (at your option) any *
* later version. This program is distributed without any warranty. See *
* the file COPYING.gpl-v3 for details. *
\*************************************************************************/
/* Listing 12-2 */
#ifdef __linux__
#define _GNU_SOURCE
#endif
#include <sys/utsname.h>
#include "tlpi_hdr.h"
int
main(int argc, char *argv[])
{
struct utsname uts;
if (uname(&uts) == -1)
errExit("uname");
printf("Node name: %s\n", uts.nodename);
printf("System name: %s\n", uts.sysname);
printf("Release: %s\n", uts.release);
printf("Version: %s\n", uts.version);
printf("Machine: %s\n", uts.machine);
#ifdef _GNU_SOURCE
printf("Domain name: %s\n", uts.domainname);
#endif
exit(EXIT_SUCCESS);
}