projects
/
suckless
/
slstatus.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
fb440d8
)
hostname: use POSIX routine to get hostname rather than reading from procfs
author
Ali H. Fardan
<raiz@firemail.cc>
Sat, 8 Oct 2016 16:55:25 +0000
(19:55 +0300)
committer
Ali H. Fardan
<raiz@firemail.cc>
Sat, 8 Oct 2016 16:55:25 +0000
(19:55 +0300)
slstatus.c
patch
|
blob
|
history
diff --git
a/slstatus.c
b/slstatus.c
index ba7f95a2a8b439955430753a1f5e1a7ca716b543..641730515d9953b56a33973426ba0d448ff4d80f 100644
(file)
--- a/
slstatus.c
+++ b/
slstatus.c
@@
-271,14
+271,10
@@
hostname(void)
char buf[HOST_NAME_MAX];
FILE *fp;
- fp = fopen("/proc/sys/kernel/hostname", "r");
- if (fp == NULL) {
- warn("Failed to open file /proc/sys/kernel/hostname");
+ if (gethostname(buf, sizeof(buf)) == -1) {
+ warn(1, "hostname");
return smprintf(UNKNOWN_STR);
}
- fgets(buf, sizeof(buf), fp);
- buf[strlen(buf)-1] = '\0';
- fclose(fp);
return smprintf("%s", buf);
}