diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2016-03-18 10:36:22 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2016-03-18 10:36:22 +1300 |
commit | 79807255feef41b15e91f5c0e82124f83c582517 (patch) | |
tree | c799b900fcadca5c736ac5a2ad98462f594a6209 /hostname.c | |
parent | Wrote whoami(1) (diff) | |
download | tunics-79807255feef41b15e91f5c0e82124f83c582517.tar.gz tunics-79807255feef41b15e91f5c0e82124f83c582517.zip |
Add hostname(1) implementation
Diffstat (limited to 'hostname.c')
-rw-r--r-- | hostname.c | 13 |
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); +} + |