X-Git-Url: http://www.dolda2000.com/gitweb/?a=blobdiff_plain;f=lib%2Fproc.c;h=86464348f625fb125c7e3ce2a7114bc7e45f7fc2;hb=6a7a868e28e79f5502cc4b37578c263f640439c8;hp=f4611d516b4adf6c5985570acb3f7334f184a906;hpb=cceb36110d6caa3a44827652d836ac6862d17ff9;p=ashd.git diff --git a/lib/proc.c b/lib/proc.c index f4611d5..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); @@ -84,7 +86,7 @@ int sendfd(int sock, int fd, char *data, size_t datalen) int recvfd(int sock, char **data, size_t *datalen) { int ret, fd; - char *buf, cbuf[1024];; + char *buf, cbuf[1024]; struct msghdr msg; struct cmsghdr *cmsg; struct iovec bufvec; @@ -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++)