X-Git-Url: http://www.dolda2000.com/gitweb/?p=ashd.git;a=blobdiff_plain;f=lib%2Fproc.c;h=86464348f625fb125c7e3ce2a7114bc7e45f7fc2;hp=2e61e92501581bff2122b1920d60bdca6683827f;hb=6a7a868e28e79f5502cc4b37578c263f640439c8;hpb=23c627d263701656532d63fade39da08072b56cf diff --git a/lib/proc.c b/lib/proc.c index 2e61e92..8646434 100644 --- a/lib/proc.c +++ b/lib/proc.c @@ -31,7 +31,7 @@ #include #include -int stdmkchild(char **argv) +int stdmkchild(char **argv, void (*chinit)(void *), void *idata) { int i; pid_t pid; @@ -42,6 +42,8 @@ int stdmkchild(char **argv) if((pid = fork()) < 0) return(-1); if(pid == 0) { + if(chinit != NULL) + chinit(idata); for(i = 3; i < FD_SETSIZE; i++) { if(i != fd[0]) close(i); @@ -124,7 +126,7 @@ int recvfd(int sock, char **data, size_t *datalen) return(fd); } -pid_t stdforkserve(char **argv, struct hthead *req, int fd) +pid_t stdforkserve(char **argv, struct hthead *req, int fd, void (*chinit)(void *), void *idata) { int i; char *ebuf, *p; @@ -134,6 +136,9 @@ pid_t stdforkserve(char **argv, struct hthead *req, int fd) if((pid = fork()) < 0) return(-1); if(pid == 0) { + if(chinit != NULL) + chinit(idata); + dup2(fd, 0); dup2(fd, 1); for(i = 3; i < FD_SETSIZE; i++)