aboutsummaryrefslogtreecommitdiff
path: root/src/iperf_client_api.c
diff options
context:
space:
mode:
authorJef Poskanzer <jef@mail.acme.com>2013-10-29 15:03:17 -0700
committerJef Poskanzer <jef@mail.acme.com>2013-10-29 15:03:17 -0700
commitafe6222a896e113d64f40f357a64d8a830c99ddc (patch)
tree2606021d51fd89dec3848d9b3c5fc88d940e2374 /src/iperf_client_api.c
parent7639c1a631089bd7a1e5e0aabfdf7dde3809fb02 (diff)
downloadiperf3-afe6222a896e113d64f40f357a64d8a830c99ddc.tar.gz
Move termination signal handing from main into iperf_run_client
and iperf_run_server, so that API users get it too. Also, call iperf_errexit with an appropriate message, which in -J mode dumps out any accumulated JSON data.
Diffstat (limited to 'src/iperf_client_api.c')
-rw-r--r--src/iperf_client_api.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/iperf_client_api.c b/src/iperf_client_api.c
index fe6a970..1f5718f 100644
--- a/src/iperf_client_api.c
+++ b/src/iperf_client_api.c
@@ -300,6 +300,15 @@ sigalrm_handler(int sig)
}
+static jmp_buf sigend_jmp_buf;
+
+static void
+sigend_handler(int sig)
+{
+ longjmp(sigend_jmp_buf, 1);
+}
+
+
int
iperf_run_client(struct iperf_test * test)
{
@@ -311,6 +320,11 @@ iperf_run_client(struct iperf_test * test)
fd_set read_set, write_set;
struct timeval now;
+ /* Termination signals. */
+ iperf_catch_sigend(sigend_handler);
+ if (setjmp(sigend_jmp_buf))
+ iperf_got_sigend(test);
+
if (test->affinity != -1)
if (iperf_setaffinity(test->affinity) != 0)
return -1;