aboutsummaryrefslogtreecommitdiff
path: root/hostname.c
diff options
context:
space:
mode:
Diffstat (limited to 'hostname.c')
-rw-r--r--hostname.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/hostname.c b/hostname.c
new file mode 100644
index 0000000..532fc16
--- /dev/null
+++ b/hostname.c
@@ -0,0 +1,13 @@
+#include "hostname.h"
+
+int main(void) {
+ struct utsname *name;
+ name = malloc(sizeof(struct utsname));
+ if (uname(name) == -1) {
+ perror("uname");
+ exit(EXIT_FAILURE);
+ }
+ fprintf(stdout, "%s\n", name->nodename);
+ exit(EXIT_SUCCESS);
+}
+