1 --- apmd-3.2.2.orig/apmd.c
13 /* Capture the child's output, if any, but only until it terminates */
15 fcntl(fds[0], F_SETFL, O_RDONLY|O_NONBLOCK);
16 - time_limit = time(0) + proxy_timeout;
17 + countdown = proxy_timeout;
20 while ((len = read(fds[0], line, sizeof(line)-1)) > 0) {
22 APMD_SYSLOG(LOG_INFO, "+ %s", line);
28 + while (sleep(1) > 0) ;
30 - (time(0) < time_limit)
32 || (proxy_timeout < 0)
35 APMD_SYSLOG(LOG_NOTICE, "Proxy has been running more than %d seconds; killing it", proxy_timeout);
38 - time_limit = time(0) + 5;
41 retval = waitpid(pid, &status, WNOHANG);
48 + while (sleep(1) > 0) ;
50 - } while (time(0) < time_limit);
51 + } while (countdown >= 0);
54 status = __W_EXITCODE(0, SIGKILL);