  	}
  }
  
-@@ -589,12 +789,43 @@ master_main(char **argv, int waitattach,
+@@ -589,12 +801,43 @@ master_main(char **argv, int waitattach,
  {
  	int fd[2] = {-1, -1};
  	int s;

+						epoll_ctl(efd, EPOLL_CTL_MOD, peer_pty, &edge_peer);
+						is_edge_mode = 1;
+					}
+					printf("EPOLL HUP\n");
+				}
+				else
+				{
+					close(events[i].data.fd);
+					if (events[i].data.fd == the_pty.fd)
+						exit(1);
+					continue;

 		return 0;
 	}
 
@@ -670,7 +913,7 @@ master_main(char **argv, int waitattach,
 		/* Child - this becomes the master */
 		if (fd[0] != -1)
 			close(fd[0]);
