Cleanup when remote side exits.

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@739 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Johan Danielsson
1996-09-15 16:27:33 +00:00
parent 234a5f7a3a
commit 8ec9e5d7ec

View File

@@ -22,6 +22,15 @@ fatal (int fd, char *s)
return err;
}
static void
cleanup()
{
if(xauthfile[0])
unlink(xauthfile);
if(x_socket[0])
unlink(x_socket);
}
static int
recv_conn (int sock, des_cblock *key, des_key_schedule schedule,
struct sockaddr_in *retaddr)
@@ -217,12 +226,27 @@ doit(int sock)
if (krb_net_read (sock, &thataddr.sin_port, sizeof(thataddr.sin_port))
!= sizeof(thataddr.sin_port))
return 1;
for (;;) {
pid_t child;
int fd;
int zero = 0;
fd_set fds;
fd = accept (localx, NULL, &zero);
FD_ZERO(&fds);
FD_SET(localx, &fds);
FD_SET(sock, &fds);
if(select(FD_SETSIZE, &fds, NULL, NULL, NULL) <=0)
continue;
if(FD_ISSET(sock, &fds)){
/* there are no processes left on the remote side
*/
cleanup();
exit(0);
}else if(FD_ISSET(localx, &fds))
fd = accept (localx, NULL, &zero);
else
continue;
if (fd < 0)
if (errno == EINTR)
continue;