Skip to content

Commit

Permalink
agetty: call uname() only when necessary
Browse files Browse the repository at this point in the history
Signed-off-by: Karel Zak <kzak@redhat.com>
  • Loading branch information
karelzak committed Jul 20, 2016
1 parent 1132e5a commit 10e8d7a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions term-utils/agetty.c
Expand Up @@ -2342,8 +2342,6 @@ static void output_special_char(unsigned char c, struct options *op,
{
struct utsname uts;

uname(&uts);

switch (c) {
case 'e':
{
Expand All @@ -2358,18 +2356,23 @@ static void output_special_char(unsigned char c, struct options *op,
break;
}
case 's':
uname(&uts);
printf("%s", uts.sysname);
break;
case 'n':
uname(&uts);
printf("%s", uts.nodename);
break;
case 'r':
uname(&uts);
printf("%s", uts.release);
break;
case 'v':
uname(&uts);
printf("%s", uts.version);
break;
case 'm':
uname(&uts);
printf("%s", uts.machine);
break;
case 'o':
Expand Down Expand Up @@ -2461,6 +2464,7 @@ static void output_special_char(unsigned char c, struct options *op,

/* \S and PRETTY_NAME not found */
} else {
uname(&uts);
fputs(uts.sysname, stdout);
}
break;
Expand Down

0 comments on commit 10e8d7a

Please sign in to comment.