Skip to content

Commit

Permalink
Enable writing to pidfile in client mode (esnet#1110)
Browse files Browse the repository at this point in the history
  • Loading branch information
wjowsa authored and hanvari committed Jul 3, 2021
1 parent 0622241 commit d273cf1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/iperf3.1
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ set server port to listen on/connect to to \fIn\fR (default 5201)
pause \fIn\fR seconds between periodic throughput reports;
default is 1, use 0 to disable
.TP
.BR -I ", " --pidfile " \fIfile\fR"
write a file with the process ID, most useful when running as a daemon.
.TP
.BR -F ", " --file " \fIname\fR"
Use a file as the source (on the sender) or sink (on the receiver) of
data, rather than just generating random data or throwing it away.
Expand Down Expand Up @@ -186,9 +189,6 @@ run in server mode
.BR -D ", " --daemon " "
run the server in background as a daemon
.TP
.BR -I ", " --pidfile " \fIfile\fR"
write a file with the process ID, most useful when running as a daemon.
.TP
.BR -1 ", " --one-off
handle one client connection, then exit.
.TP
Expand Down
1 change: 0 additions & 1 deletion src/iperf_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1336,7 +1336,6 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
break;
case 'I':
test->pidfile = strdup(optarg);
server_flag = 1;
break;
case OPT_LOGFILE:
test->logfile = strdup(optarg);
Expand Down
2 changes: 1 addition & 1 deletion src/iperf_locale.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ const char usage_longstr[] = "Usage: iperf3 [-s|-c host] [options]\n"
" -p, --port # server port to listen on/connect to\n"
" -f, --format [kmgtKMGT] format to report: Kbits, Mbits, Gbits, Tbits\n"
" -i, --interval # seconds between periodic throughput reports\n"
" -I, --pidfile file write PID file\n"
" -F, --file name xmit/recv the specified file\n"
#if defined(HAVE_CPU_AFFINITY)
" -A, --affinity n/n,m set CPU affinity\n"
Expand All @@ -121,7 +122,6 @@ const char usage_longstr[] = "Usage: iperf3 [-s|-c host] [options]\n"
"Server specific:\n"
" -s, --server run in server mode\n"
" -D, --daemon run the server as a daemon\n"
" -I, --pidfile file write PID file\n"
" -1, --one-off handle one client connection then exit\n"
" --server-bitrate-limit #[KMG][/#] server's total bit rate limit (default 0 = no limit)\n"
" (optional slash and number of secs interval for averaging\n"
Expand Down
5 changes: 5 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,13 @@ run(struct iperf_test *test)
iperf_delete_pidfile(test);
break;
case 'c':
if (iperf_create_pidfile(test) < 0) {
i_errno = IEPIDFILE;
iperf_errexit(test, "error - %s", iperf_strerror(i_errno));
}
if (iperf_run_client(test) < 0)
iperf_errexit(test, "error - %s", iperf_strerror(i_errno));
iperf_delete_pidfile(test);
break;
default:
usage();
Expand Down

0 comments on commit d273cf1

Please sign in to comment.