Matt McCutchen's Web Site
/
rsync
/
rsync.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add --compare-dest option which enables specifying an additional destination
[rsync/rsync.git]
/
socket.c
diff --git
a/socket.c
b/socket.c
index
f8d4659
..
6551df4
100644
(file)
--- a/
socket.c
+++ b/
socket.c
@@
-54,6
+54,8
@@
int open_socket_out(char *host, int port)
return -1;
}
return -1;
}
+ set_nonblocking(res);
+
return res;
}
return res;
}
@@
-110,9
+112,9
@@
determine if a file descriptor is in fact a socket
****************************************************************************/
int is_a_socket(int fd)
{
****************************************************************************/
int is_a_socket(int fd)
{
- int v,l;
- l = sizeof(int);
- return(getsockopt(fd, SOL_SOCKET, SO_TYPE, (char *)&v, &l) == 0);
+
int v,l;
+
l = sizeof(int);
+
return(getsockopt(fd, SOL_SOCKET, SO_TYPE, (char *)&v, &l) == 0);
}
}
@@
-165,6
+167,8
@@
void start_accept_loop(int port, int (*fn)(int ))
if (fork()==0) {
close(s);
if (fork()==0) {
close(s);
+ set_nonblocking(fd);
+
_exit(fn(fd));
}
_exit(fn(fd));
}
@@
-283,21
+287,19
@@
void become_daemon(void)
{
int i;
{
int i;
- if (fork())
+ if (fork())
{
_exit(0);
_exit(0);
+ }
/* detach from the terminal */
#ifdef HAVE_SETSID
setsid();
#else
#ifdef TIOCNOTTY
/* detach from the terminal */
#ifdef HAVE_SETSID
setsid();
#else
#ifdef TIOCNOTTY
- {
- int i = open("/dev/tty", O_RDWR);
- if (i >= 0)
- {
- ioctl(i, (int) TIOCNOTTY, (char *)0);
- close(i);
- }
+ i = open("/dev/tty", O_RDWR);
+ if (i >= 0) {
+ ioctl(i, (int) TIOCNOTTY, (char *)0);
+ close(i);
}
#endif /* TIOCNOTTY */
#endif
}
#endif /* TIOCNOTTY */
#endif