1
0
Fork 0
mirror of https://repo.or.cz/socat.git synced 2025-07-14 15:23:24 +00:00

merged features ancillary, envvar

This commit is contained in:
Gerhard Rieger 2008-09-22 22:17:55 +02:00
parent bd3810642b
commit 2ffe5a324e
42 changed files with 1898 additions and 287 deletions

View file

@ -104,30 +104,24 @@ int xioopen_ipapp_connect(int argc, const char *argv[], struct opt *opts,
#if WITH_RETRY
if (dofork) {
pid_t pid;
while ((pid = Fork()) < 0) {
int level = E_ERROR;
if (xfd->forever || --xfd->retry) {
level = E_WARN; /* most users won't expect a problem here,
int level = E_ERROR;
if (xfd->forever || xfd->retry) {
level = E_WARN; /* most users won't expect a problem here,
so Notice is too weak */
}
Msg1(level, "fork(): %s", strerror(errno));
if (xfd->forever || xfd->retry) {
dropopts(opts, PH_ALL); opts = copyopts(opts0, GROUP_ALL);
}
while ((pid = xio_fork(false, level)) < 0) {
if (xfd->forever || --xfd->retry) {
Nanosleep(&xfd->intervall, NULL); continue;
}
return STAT_RETRYLATER;
}
if (pid == 0) { /* child process */
Info1("just born: TCP client process "F_pid, Getpid());
/* drop parents locks, reset FIPS... */
if (xio_forked_inchild() != 0) {
Exit(1);
}
if (pid == 0) { /* child process */
xfd->forever = false; xfd->retry = 0;
break;
}
/* parent process */
Notice1("forked off child process "F_pid, pid);
Close(xfd->fd);
/* with and without retry */
Nanosleep(&xfd->intervall, NULL);
@ -139,6 +133,7 @@ int xioopen_ipapp_connect(int argc, const char *argv[], struct opt *opts,
break;
}
} while (true);
/* only "active" process breaks (master without fork, or child) */
if ((result = _xio_openlate(xfd, opts)) < 0) {
return result;