Browse Source

Fix leaving zombie process with include_shell (#1777)

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2319 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.21
Stefan Bühler 13 years ago
parent
commit
b66dc12fda
  1. 1
      NEWS
  2. 3
      src/configfile.c
  3. 25
      src/proc_open.c
  4. 2
      src/proc_open.h

1
NEWS

@ -9,6 +9,7 @@ NEWS
* Fix mod_cgi segfault when bound to unix domain socket (#653)
* Do not rely on ioctl FIONREAD (#673)
* Now really fix mod auth ldap (#1066)
* Fix leaving zombie process with include_shell (#1777)
- 1.4.20 - 2008-09-30

3
src/configfile.c

@ -940,7 +940,6 @@ static char* getCWD() {
}
int config_parse_cmd(server *srv, config_t *context, const char *cmd) {
proc_handler_t proc;
tokenizer_t t;
int ret;
buffer *source;
@ -960,7 +959,7 @@ int config_parse_cmd(server *srv, config_t *context, const char *cmd) {
chdir(context->basedir->ptr);
}
if (0 != proc_open_buffer(&proc, cmd, NULL, out, NULL)) {
if (0 != proc_open_buffer(cmd, NULL, out, NULL)) {
log_error_write(srv, __FILE__, __LINE__, "sbss",
"opening", source, "failed:", strerror(errno));
ret = -1;

25
src/proc_open.c

@ -287,31 +287,32 @@ static void proc_read_fd_to_buffer(int fd, buffer *b) {
}
/* }}} */
/* {{{ proc_open_buffer */
int proc_open_buffer(proc_handler_t *proc, const char *command, buffer *in, buffer *out, buffer *err) {
UNUSED(err);
int proc_open_buffer(const char *command, buffer *in, buffer *out, buffer *err) {
proc_handler_t proc;
if (proc_open(proc, command) != 0) {
if (proc_open(&proc, command) != 0) {
return -1;
}
if (in) {
if (write(proc->in.fd, (void *)in->ptr, in->used) < 0) {
if (write(proc.in.fd, (void *)in->ptr, in->used) < 0) {
perror("error writing pipe");
return -1;
}
}
pipe_close(&proc->in);
pipe_close(&proc.in);
if (out) {
proc_read_fd_to_buffer(proc->out.fd, out);
proc_read_fd_to_buffer(proc.out.fd, out);
}
pipe_close(&proc->out);
pipe_close(&proc.out);
if (err) {
proc_read_fd_to_buffer(proc->err.fd, err);
proc_read_fd_to_buffer(proc.err.fd, err);
}
pipe_close(&proc->err);
pipe_close(&proc.err);
proc_close(&proc);
return 0;
}
@ -366,7 +367,7 @@ int main() {
RESET();
fprintf(stdout, "test: echo 321 with read\n"); fflush(stdout);
if (proc_open_buffer(&proc, "echo 321", NULL, out, err) != 0) {
if (proc_open_buffer("echo 321", NULL, out, err) != 0) {
ERROR_OUT();
}
fprintf(stdout, "result: ->%s<-\n\n", out->ptr); fflush(stdout);
@ -374,7 +375,7 @@ int main() {
fprintf(stdout, "test: echo 123 | " CMD_CAT "\n"); fflush(stdout);
buffer_copy_string_len(in, CONST_STR_LEN("123\n"));
if (proc_open_buffer(&proc, CMD_CAT, in, out, err) != 0) {
if (proc_open_buffer(CMD_CAT, in, out, err) != 0) {
ERROR_OUT();
}
fprintf(stdout, "result: ->%s<-\n\n", out->ptr); fflush(stdout);

2
src/proc_open.h

@ -22,4 +22,4 @@ typedef struct {
int proc_close(proc_handler_t *ht);
int proc_open(proc_handler_t *ht, const char *command);
int proc_open_buffer(proc_handler_t *ht, const char *command, buffer *in, buffer *out, buffer *err);
int proc_open_buffer(const char *command, buffer *in, buffer *out, buffer *err);

Loading…
Cancel
Save