Replace system("uname -a") with call to uname(3).
Slightly reworked version of a patch that was... Submitted by: Susant Sahani <ssahani@redhat.com>
Этот коммит содержится в:
родитель
441d8b75a0
Коммит
9a829841eb
@ -588,8 +588,7 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
|
||||
test->json_output = 1;
|
||||
break;
|
||||
case 'v':
|
||||
printf("%s\n", version);
|
||||
system("uname -a");
|
||||
printf("%s\n%s\n", version, get_system_info());
|
||||
exit(0);
|
||||
case 's':
|
||||
if (test->role == 'c') {
|
||||
|
@ -356,7 +356,7 @@ iperf_run_client(struct iperf_test * test)
|
||||
iprintf(test, "%s\n", version);
|
||||
iprintf(test, "%s", "");
|
||||
fflush(stdout);
|
||||
system("uname -a");
|
||||
printf("%s\n", get_system_info());
|
||||
}
|
||||
|
||||
/* Start the client and connect to the server */
|
||||
|
@ -450,7 +450,7 @@ iperf_run_server(struct iperf_test *test)
|
||||
iprintf(test, "%s\n", version);
|
||||
iprintf(test, "%s", "");
|
||||
fflush(stdout);
|
||||
system("uname -a");
|
||||
printf("%s\n", get_system_info());
|
||||
}
|
||||
|
||||
// Open socket and listen
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009-2011, The Regents of the University of California,
|
||||
* Copyright (c) 2009-2014, The Regents of the University of California,
|
||||
* through Lawrence Berkeley National Laboratory (subject to receipt of any
|
||||
* required approvals from the U.S. Dept. of Energy). All rights reserved.
|
||||
*
|
||||
@ -22,6 +22,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
|
||||
@ -193,19 +194,20 @@ cpu_util(double pcpu[3])
|
||||
pcpu[2] = (systemdiff / timediff) * 100;
|
||||
}
|
||||
|
||||
char*
|
||||
char *
|
||||
get_system_info(void)
|
||||
{
|
||||
FILE* fp;
|
||||
static char buf[1000];
|
||||
{
|
||||
static char buf[1024];
|
||||
struct utsname uts;
|
||||
|
||||
memset(buf, 0, 1024);
|
||||
uname(&uts);
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s %s %s %s %s", uts.sysname, uts.nodename,
|
||||
uts.release, uts.version, uts.machine);
|
||||
|
||||
fp = popen("uname -a", "r");
|
||||
if (fp == NULL)
|
||||
return NULL;
|
||||
fgets(buf, sizeof(buf), fp);
|
||||
pclose(fp);
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Helper routine for building cJSON objects in a printf-like manner.
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user