Changeset 1223
- Timestamp:
- 03/07/08 00:09:48 (6 months ago)
- Files:
-
- 1.8.3/branches/devel/src/info_master.c (modified) (3 diffs)
- 1.8.3/branches/devel/src/info_slave.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
1.8.3/branches/devel/src/info_master.c
r1158 r1223 94 94 { 95 95 int socks[2]; 96 char num[NI_MAXSERV];97 96 pid_t child; 98 97 int n; … … 140 139 } else { 141 140 int errfd = fileno(stderr); 142 /* Close unneeded fds and sockets: Everything but stdout and the socket used to talk to the mush */ 141 int dupfd; 142 143 /* Close unneeded fds and sockets: Everything but stderr and the 144 socket used to talk to the mush */ 143 145 for (n = 0; n < maxd; n++) { 144 146 if (n == errfd) … … 150 152 close(n); 151 153 } 152 snprintf(num, NI_MAXSERV, "%d", socks[1]); 153 execl("./info_slave", "info_slave", num, (char *) NULL); 154 /* Reuse stdin and stdout for talking to the slave */ 155 dupfd = dup2(socks[1], 0); 156 if (dupfd < 0) { 157 penn_perror("dup2() of stdin in info_slave"); 158 exit(1); 159 } 160 161 dupfd = dup2(socks[1], 1); 162 if (dupfd < 0) { 163 penn_perror("dup2() of stdout in info_slave"); 164 exit(1); 165 } 166 167 close(socks[1]); 168 169 execl("./info_slave", "info_slave", (char *) NULL); 154 170 penn_perror("execing info slave"); 155 _exit(1);171 exit(1); 156 172 } 157 173 1.8.3/branches/devel/src/info_slave.c
r1164 r1223 87 87 88 88 int 89 main(int argc, char *argv[]) 90 { 91 int mush, port; 89 main(void) 90 { 92 91 struct request_dgram req; 93 92 struct response_dgram resp; … … 96 95 char localport[NI_MAXSERV]; 97 96 98 if (argc < 2) {99 fputerr("info_slave needs a port number!");100 return EXIT_FAILURE;101 }102 port = strtol(argv[1], NULL, 10);103 104 mush = port; /* We inherit open file descriptors and sockets from parent */105 106 97 if (new_process_group() < 0) 107 98 penn_perror("making new process group"); … … 116 107 } 117 108 118 if (eventwait_watch_fd_read( mush) < 0) {109 if (eventwait_watch_fd_read(0) < 0) { 119 110 penn_perror("eventwait_add_fd"); 120 111 return EXIT_FAILURE; … … 135 126 int ev = eventwait(); 136 127 137 if (ev == mush)138 len = recv( mush, &req, sizeof req, 0);128 if (ev == 0) 129 len = recv(0, &req, sizeof req, 0); 139 130 else if (ev == (int) netmush) { 140 131 /* Parent process exited. Exit too. */ … … 217 208 strcpy(resp.hostname, resp.ipaddr); 218 209 219 len = send( mush, &resp, sizeof resp, 0);210 len = send(1, &resp, sizeof resp, 0); 220 211 221 212 /* Should never happen. */
