X-Git-Url: http://www.dolda2000.com/gitweb/?a=blobdiff_plain;f=lib%2Fproc.c;h=86464348f625fb125c7e3ce2a7114bc7e45f7fc2;hb=330c9bc3a9008ac4937e79e80a0d383ce082f7c1;hp=2e61e92501581bff2122b1920d60bdca6683827f;hpb=3a42b6b1d0b8f9e8ce5c77e838e2573bbfabe593;p=ashd.git 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++)