]> pilppa.org Git - familiar-h63xx-build.git/blob - org.handhelds.familiar/packages/apmd/apmd-3.2.2/debian.patch
OE tree imported from monotone branch org.openembedded.oz354fam083 at revision 8b12e3...
[familiar-h63xx-build.git] / org.handhelds.familiar / packages / apmd / apmd-3.2.2 / debian.patch
1 --- apmd-3.2.2.orig/apmd.c
2 +++ apmd-3.2.2/apmd.c
3 @@ -343,7 +343,7 @@
4                 /* parent */
5                 int status, retval;
6                 ssize_t len;
7 -               time_t time_limit;
8 +               time_t countdown;
9  
10                 if (pid < 0) {
11                         /* Couldn't fork */
12 @@ -356,8 +356,9 @@
13                 /* Capture the child's output, if any, but only until it terminates */
14                 close(fds[1]);
15                 fcntl(fds[0], F_SETFL, O_RDONLY|O_NONBLOCK);
16 -               time_limit = time(0) + proxy_timeout;
17 +               countdown = proxy_timeout;
18                 do {
19 +                       countdown -= 1;
20                         while ((len = read(fds[0], line, sizeof(line)-1)) > 0) {
21                                 line[len] = 0;
22                                 APMD_SYSLOG(LOG_INFO, "+ %s", line);
23 @@ -372,16 +373,16 @@
24                                 goto proxy_done;
25                         }
26                                 
27 -                       sleep(1);
28 +                       while (sleep(1) > 0) ;
29                 } while (
30 -                       (time(0) < time_limit)
31 +                       (countdown >= 0)
32                         || (proxy_timeout < 0)
33                 );
34  
35                 APMD_SYSLOG(LOG_NOTICE, "Proxy has been running more than %d seconds; killing it", proxy_timeout);
36  
37                 kill(pid, SIGTERM);
38 -               time_limit = time(0) + 5;
39 +               countdown = 5;
40                 do {
41                         retval = waitpid(pid, &status, WNOHANG);
42                         if (retval == pid)
43 @@ -392,9 +393,9 @@
44                                 goto proxy_done;
45                         }
46  
47 -                       sleep(1);
48 +                       while (sleep(1) > 0) ;
49  
50 -               } while (time(0) < time_limit);
51 +               } while (countdown >= 0);
52  
53                 kill(pid, SIGKILL);
54                 status = __W_EXITCODE(0, SIGKILL);