masqmail
diff src/child.c @ 401:885e3d886199
Various minor refactoring.
author | markus schnalke <meillo@marmaro.de> |
---|---|
date | Tue, 21 Feb 2012 16:11:00 +0100 |
parents | 0ca270ca11fa |
children |
line diff
1.1 --- a/src/child.c Tue Feb 21 15:44:55 2012 +0100 1.2 +++ b/src/child.c Tue Feb 21 16:11:00 2012 +0100 1.3 @@ -41,26 +41,28 @@ 1.4 pid = fork(); 1.5 if (pid == -1) { 1.6 return -1; 1.7 + 1.8 } else if (pid == 0) { 1.9 /* child */ 1.10 + char *argv[] = { "/bin/sh", "-c", (char *)command, 1.11 + NULL }; 1.12 int i, max_fd = sysconf(_SC_OPEN_MAX); 1.13 + 1.14 dup2(pipe[0], 0); 1.15 dup2(pipe[0], 1); 1.16 dup2(pipe[0], 2); 1.17 1.18 - if (max_fd <= 0) 1.19 + if (max_fd <= 0) { 1.20 max_fd = 64; 1.21 - for (i = 3; i < max_fd; i++) 1.22 + } 1.23 + for (i = 3; i < max_fd; i++) { 1.24 close(i); 1.25 - 1.26 - { 1.27 - char *argv[] = { "/bin/sh", "-c", 1.28 - (char *) command, NULL }; 1.29 - execve(*argv, argv, NULL); 1.30 } 1.31 + execve(*argv, argv, NULL); 1.32 logwrite(LOG_ALERT, "execve failed: %s\n", 1.33 strerror(errno)); 1.34 _exit(1); 1.35 + 1.36 } else { 1.37 /* parent */ 1.38 close(pipe[0]);