|
Lines 1821-1855
main(int ac, char **av)
Link Here
|
| 1821 |
int fd; |
1821 |
int fd; |
| 1822 |
|
1822 |
|
| 1823 |
debug("rexec start in %d out %d newsock %d pipe %d sock %d", |
1823 |
debug("rexec start in %d out %d newsock %d pipe %d sock %d", |
| 1824 |
sock_in, sock_out, newsock, startup_pipe, config_s[0]); |
1824 |
sock_in, sock_out, newsock, startup_pipe, config_s[0]); |
| 1825 |
dup2(newsock, STDIN_FILENO); |
1825 |
dup2(newsock, STDIN_FILENO); |
| 1826 |
dup2(STDIN_FILENO, STDOUT_FILENO); |
1826 |
dup2(STDIN_FILENO, STDOUT_FILENO); |
| 1827 |
if (startup_pipe == -1) |
1827 |
if (startup_pipe == -1) |
| 1828 |
close(REEXEC_STARTUP_PIPE_FD); |
1828 |
close(REEXEC_STARTUP_PIPE_FD); |
| 1829 |
else |
1829 |
else if (startup_pipe != REEXEC_STARTUP_PIPE_FD) { |
| 1830 |
dup2(startup_pipe, REEXEC_STARTUP_PIPE_FD); |
1830 |
dup2(startup_pipe, REEXEC_STARTUP_PIPE_FD); |
|
|
1831 |
close(startup_pipe); |
| 1832 |
startup_pipe = REEXEC_STARTUP_PIPE_FD; |
| 1833 |
} |
| 1831 |
|
1834 |
|
| 1832 |
dup2(config_s[1], REEXEC_CONFIG_PASS_FD); |
1835 |
dup2(config_s[1], REEXEC_CONFIG_PASS_FD); |
| 1833 |
close(config_s[1]); |
1836 |
close(config_s[1]); |
| 1834 |
if (startup_pipe != -1) |
|
|
| 1835 |
close(startup_pipe); |
| 1836 |
|
1837 |
|
| 1837 |
execv(rexec_argv[0], rexec_argv); |
1838 |
execv(rexec_argv[0], rexec_argv); |
| 1838 |
|
1839 |
|
| 1839 |
/* Reexec has failed, fall back and continue */ |
1840 |
/* Reexec has failed, fall back and continue */ |
| 1840 |
error("rexec of %s failed: %s", rexec_argv[0], strerror(errno)); |
1841 |
error("rexec of %s failed: %s", rexec_argv[0], strerror(errno)); |
| 1841 |
recv_rexec_state(REEXEC_CONFIG_PASS_FD, NULL); |
1842 |
recv_rexec_state(REEXEC_CONFIG_PASS_FD, NULL); |
| 1842 |
log_init(__progname, options.log_level, |
1843 |
log_init(__progname, options.log_level, |
| 1843 |
options.log_facility, log_stderr); |
1844 |
options.log_facility, log_stderr); |
| 1844 |
|
1845 |
|
| 1845 |
/* Clean up fds */ |
1846 |
/* Clean up fds */ |
| 1846 |
startup_pipe = REEXEC_STARTUP_PIPE_FD; |
|
|
| 1847 |
close(config_s[1]); |
| 1848 |
close(REEXEC_CONFIG_PASS_FD); |
1847 |
close(REEXEC_CONFIG_PASS_FD); |
| 1849 |
newsock = sock_out = sock_in = dup(STDIN_FILENO); |
1848 |
newsock = sock_out = sock_in = dup(STDIN_FILENO); |
| 1850 |
if ((fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) { |
1849 |
if ((fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) { |
| 1851 |
dup2(fd, STDIN_FILENO); |
1850 |
dup2(fd, STDIN_FILENO); |
| 1852 |
dup2(fd, STDOUT_FILENO); |
1851 |
dup2(fd, STDOUT_FILENO); |
| 1853 |
if (fd > STDERR_FILENO) |
1852 |
if (fd > STDERR_FILENO) |
| 1854 |
close(fd); |
1853 |
close(fd); |
| 1855 |
} |
1854 |
} |