=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/rdist/child.c,v retrieving revision 1.5 retrieving revision 1.6 diff -c -r1.5 -r1.6 *** src/usr.bin/rdist/child.c 1997/08/04 19:25:54 1.5 --- src/usr.bin/rdist/child.c 1997/12/16 22:15:36 1.6 *************** *** 1,4 **** ! /* $OpenBSD: child.c,v 1.5 1997/08/04 19:25:54 deraadt Exp $ */ /* * Copyright (c) 1983 Regents of the University of California. --- 1,4 ---- ! /* $OpenBSD: child.c,v 1.6 1997/12/16 22:15:36 deraadt Exp $ */ /* * Copyright (c) 1983 Regents of the University of California. *************** *** 35,41 **** #ifndef lint static char RCSid[] = ! "$OpenBSD: child.c,v 1.5 1997/08/04 19:25:54 deraadt Exp $"; static char sccsid[] = "@(#)docmd.c 5.1 (Berkeley) 6/6/85"; --- 35,41 ---- #ifndef lint static char RCSid[] = ! "$OpenBSD: child.c,v 1.6 1997/12/16 22:15:36 deraadt Exp $"; static char sccsid[] = "@(#)docmd.c 5.1 (Berkeley) 6/6/85"; *************** *** 364,370 **** #if defined(HAVE_SELECT) register int count; register CHILD *pc; ! fd_set rchildfds; debugmsg(DM_CALL, "waitup() start\n"); --- 364,372 ---- #if defined(HAVE_SELECT) register int count; register CHILD *pc; ! fd_set *rchildfdsp = NULL; ! int rchildfdsn = 0; ! int bytes; debugmsg(DM_CALL, "waitup() start\n"); *************** *** 377,388 **** /* * Settup which children we want to select() on. */ - FD_ZERO(&rchildfds); for (pc = childlist; pc; pc = pc->c_next) if (pc->c_readfd > 0) { debugmsg(DM_MISC, "waitup() select on %d (%s)\n", pc->c_readfd, pc->c_name); ! FD_SET(pc->c_readfd, &rchildfds); } /* --- 379,397 ---- /* * Settup which children we want to select() on. */ for (pc = childlist; pc; pc = pc->c_next) + if (pc->c_readfd > rchildfdsn) + rchildfdsn = pc->c_readfd; + bytes = howmany(rchildfdsn+1, NFDBITS) * sizeof(fd_mask); + if ((rchildfdsp = (fd_set *)malloc(bytes)) == NULL) + return; + + memset(rchildfdsp, 0, bytes); + for (pc = childlist; pc; pc = pc->c_next) if (pc->c_readfd > 0) { debugmsg(DM_MISC, "waitup() select on %d (%s)\n", pc->c_readfd, pc->c_name); ! FD_SET(pc->c_readfd, rchildfdsp); } /* *************** *** 392,398 **** debugmsg(DM_MISC, "waitup() Call select(), activechildren=%d\n", activechildren); ! count = select(FD_SETSIZE, (SELECT_FD_TYPE *) &rchildfds, (SELECT_FD_TYPE *) NULL, (SELECT_FD_TYPE *) NULL, (struct timeval *) NULL); --- 401,407 ---- debugmsg(DM_MISC, "waitup() Call select(), activechildren=%d\n", activechildren); ! count = select(rchildfdsn+1, (SELECT_FD_TYPE *) rchildfdsp, (SELECT_FD_TYPE *) NULL, (SELECT_FD_TYPE *) NULL, (struct timeval *) NULL); *************** *** 407,412 **** --- 416,422 ---- if (errno != EINTR) error("Select failed reading children input: %s", SYSERR); + free(rchildfdsp); return; } *************** *** 415,420 **** --- 425,431 ---- */ if (count == 0) { error("Select returned an unexpected count of 0."); + free(rchildfdsp); return; } *************** *** 436,442 **** } if (pc->c_name == NULL || ! !FD_ISSET(pc->c_readfd, &rchildfds)) continue; readchild(pc); --- 447,453 ---- } if (pc->c_name == NULL || ! !FD_ISSET(pc->c_readfd, rchildfdsp)) continue; readchild(pc); *************** *** 455,460 **** --- 466,472 ---- #endif /* defined(HAVE_SELECT) */ debugmsg(DM_CALL, "waitup() end\n"); + free(rchildfdsp); } /*