-static void status_pre_select(fd_set *rfds, int *max_fileno, struct timeval *tv)
-{
- static struct timeval next_exec, atm, diff;
- int ret, fds[3] = {0, 1, 0};
- pid_t pid;
-
- if (stat_pipe >= 0)
- goto success;
- /* Avoid busy loop */
- gettimeofday(&atm, NULL);
- if (tv_diff(&next_exec, &atm, &diff) > 0) {
- if (tv_diff(&diff, tv, NULL) < 0)
- *tv = diff;
- return;
- }
- next_exec.tv_sec = atm.tv_sec + 2;
- ret = para_exec_cmdline_pid(&pid, conf.stat_cmd_arg, fds);
- if (ret < 0)
- return;
- ret = mark_fd_nonblocking(fds[1]);
- if (ret < 0) {
- close(fds[1]);
- return;
- }
- stat_pipe = fds[1];
-success:
- para_fd_set(stat_pipe, rfds, max_fileno);
-}
-