mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 02:17:35 +00:00
Add sys$gethostname and /bin/hostname
This commit is contained in:
parent
3faaa3e04a
commit
53abfa7ea1
16 changed files with 77 additions and 40 deletions
17
Userland/hostname.cpp
Normal file
17
Userland/hostname.cpp
Normal file
|
@ -0,0 +1,17 @@
|
|||
#include <LibC/unistd.h>
|
||||
#include <LibC/stdio.h>
|
||||
#include <LibC/errno.h>
|
||||
#include <LibC/string.h>
|
||||
|
||||
int main(int c, char** v)
|
||||
{
|
||||
char buffer[HOST_NAME_MAX];
|
||||
int rc = gethostname(buffer, sizeof(buffer));
|
||||
if (rc < 0) {
|
||||
printf("gethostname() error: %s\n", strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
printf("%s\n", buffer);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue