1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:47:34 +00:00

Add sys$ttyname_r and ttyname_r() + ttyname().

And print a greeting when sh starts up so we know which TTY we're on.
This commit is contained in:
Andreas Kling 2018-10-30 22:03:02 +01:00
parent 7a85384e47
commit 00c21d1590
12 changed files with 78 additions and 3 deletions

View file

@ -4,6 +4,7 @@
#include <LibC/errno.h>
#include <LibC/string.h>
#include <LibC/stdlib.h>
#include <LibC/utsname.h>
#include <AK/FileSystemPath.h>
struct GlobalState {
@ -148,6 +149,17 @@ static int runcmd(char* cmd)
return retval;
}
static void greeting()
{
utsname uts;
int rc = uname(&uts);
if (rc < 0) {
perror("uname");
return;
}
printf("\n%s/%s on %s\n\n", uts.sysname, uts.machine, ttyname(0));
}
int main(int, char**)
{
g = new GlobalState;
@ -155,6 +167,8 @@ int main(int, char**)
if (rc < 0)
perror("gethostname");
greeting();
char linebuf[128];
int linedx = 0;
linebuf[0] = '\0';