diff options
author | rwatson <rwatson@FreeBSD.org> | 2006-04-02 11:09:37 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2006-04-02 11:09:37 +0000 |
commit | 19f9c1efe47d365dd95231c4ba6a1e467157f00a (patch) | |
tree | 2e8e651f558b51f93e0413a65cee1499e8b6bc72 /tools/regression/netinet | |
parent | 02d5fc264404b64f570cca033b9962874747a98a (diff) | |
download | FreeBSD-src-19f9c1efe47d365dd95231c4ba6a1e467157f00a.zip FreeBSD-src-19f9c1efe47d365dd95231c4ba6a1e467157f00a.tar.gz |
When running the second part of the test, kill off the server process from
the first part before starting, or the TCP port we want to bind may be in
use still. Sleep for a short period between tests.
Use SIGTERM instead of SIGKILL.
Diffstat (limited to 'tools/regression/netinet')
-rw-r--r-- | tools/regression/netinet/tcpsocktimewait/tcpsocktimewait.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/tools/regression/netinet/tcpsocktimewait/tcpsocktimewait.c b/tools/regression/netinet/tcpsocktimewait/tcpsocktimewait.c index 40752ff..a5e6542 100644 --- a/tools/regression/netinet/tcpsocktimewait/tcpsocktimewait.c +++ b/tools/regression/netinet/tcpsocktimewait/tcpsocktimewait.c @@ -56,7 +56,7 @@ tcp_server(pid_t partner) listen_fd = socket(PF_INET, SOCK_STREAM, 0); if (listen_fd < 0) { error = errno; - (void)kill(partner, SIGKILL); + (void)kill(partner, SIGTERM); errno = error; err(-1, "tcp_server: socket"); } @@ -69,14 +69,14 @@ tcp_server(pid_t partner) if (bind(listen_fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) { error = errno; - (void)kill(partner, SIGKILL); + (void)kill(partner, SIGTERM); errno = error; err(-1, "tcp_server: bind"); } if (listen(listen_fd, -1) < 0) { error = errno; - (void)kill(partner, SIGKILL); + (void)kill(partner, SIGTERM); errno = error; err(-1, "tcp_server: listen"); } @@ -84,7 +84,7 @@ tcp_server(pid_t partner) accept_fd = accept(listen_fd, NULL, NULL); if (accept_fd < 0) { error = errno; - (void)kill(partner, SIGKILL); + (void)kill(partner, SIGTERM); errno = error; err(-1, "tcp_server: accept"); } @@ -103,7 +103,7 @@ tcp_client(pid_t partner, int secs) sock = socket(PF_INET, SOCK_STREAM, 0); if (sock < 0) { error = errno; - (void)kill(partner, SIGKILL); + (void)kill(partner, SIGTERM); errno = error; err(-1, "socket"); } @@ -116,14 +116,14 @@ tcp_client(pid_t partner, int secs) if (connect(sock, (struct sockaddr *)&sin, sizeof(sin)) < 0) { error = errno; - (void)kill(partner, SIGKILL); + (void)kill(partner, SIGTERM); errno = error; err(-1, "connect"); } if (shutdown(sock, SHUT_RDWR) < 0) { error = errno; - (void)kill(partner, SIGKILL); + (void)kill(partner, SIGTERM); errno = error; err(-1, "shutdown"); } @@ -152,8 +152,11 @@ main(int argc, char *argv[]) if (child_pid == 0) { child_pid = getpid(); tcp_server(child_pid); + exit(0); } else tcp_client(parent_pid, 1); + (void)kill(child_pid, SIGTERM); + sleep(5); parent_pid = getpid(); child_pid = fork(); |