aboutsummaryrefslogtreecommitdiff
path: root/toys/pending/tcpsvd.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2014-05-31 12:33:24 -0500
committerRob Landley <rob@landley.net>2014-05-31 12:33:24 -0500
commitd8872c43b48eae5501998a4e5a84337017d8fbe6 (patch)
tree8360d8673d0ed40b02f9d58bdf74b639f6e780f9 /toys/pending/tcpsvd.c
parentb0d97a0059555cb0e7e0009b72c038aa67aaa769 (diff)
downloadtoybox-d8872c43b48eae5501998a4e5a84337017d8fbe6.tar.gz
Introduce xfork() and make commands use it, and make some WEXITSTATUS() use WIFEXITED() and WTERMSIG()+127.
Diffstat (limited to 'toys/pending/tcpsvd.c')
-rw-r--r--toys/pending/tcpsvd.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/toys/pending/tcpsvd.c b/toys/pending/tcpsvd.c
index 031d7238..d7e1f6c1 100644
--- a/toys/pending/tcpsvd.c
+++ b/toys/pending/tcpsvd.c
@@ -14,7 +14,7 @@ config TCPSVD
default n
help
usage: tcpsvd [-hEv] [-c N] [-C N[:MSG]] [-b N] [-u User] [-l Name] IP Port Prog
- udpsvd [-hEv] [-c N] [-u User] [-l Name] IP Port Prog
+ usage: udpsvd [-hEv] [-c N] [-u User] [-l Name] IP Port Prog
Create TCP/UDP socket, bind to IP:PORT and listen for incoming connection.
Run PROG for each connection.
@@ -350,7 +350,7 @@ void tcpsvd_main(void)
h[hash].head->count++;
}
- if (!(pid = fork())) {
+ if (!(pid = xfork())) {
char *serv = NULL, *clie = NULL;
char *client = sock_to_address((struct sockaddr*)buf, NI_NUMERICHOST | NI_NUMERICSERV);
if (toys.optflags & FLAG_h) { //lookup name
@@ -393,11 +393,11 @@ void tcpsvd_main(void)
dup2(newfd, 0);
dup2(newfd, 1);
xexec_optargs(2); //skip IP PORT
- } else if(pid > 0) {
+ } else {
insert(&pids, pid, addr);
xclose(newfd); //close and reopen for next client.
if (TT.udp) fd = create_bind_sock(toys.optargs[0],
(struct sockaddr*)&haddr);
- } else error_msg(" fork failed");
+ }
} //while(1)
}