[procps] Re: release 3.3.3 tag annotation and watch

  • From: "Kent R. Spillner" <kspillner@xxxxxxx>
  • To: procps@xxxxxxxxxxxxx
  • Date: Fri, 16 Mar 2012 10:25:50 -0500 (CDT)

Hey, dude-

> It's a little quirky as it seems to me to exit out 2 seconds after the
> change, so its like:
>   intial output
>   changed output
>   exit

Would you prefer something like the attached diff?

Best,
Kent

-----Original Message-----
From: "Craig Small" <csmall-procps@xxxxxxxxxx>
Sent: Thursday, March 15, 2012 15:33
To: procps@xxxxxxxxxxxxx
Subject: [procps] Re: release 3.3.3 tag annotation and watch

On Sat, Mar 10, 2012 at 10:00:18PM -0600, Kent R. Spillner wrote:
>    I created a merge request that fixes the problem:
>    https://gitorious.org/procps/procps/merge_requests/3
That one is merged in and seems to be making watch do the right thing.
It's a little quirky as it seems to me to exit out 2 seconds after the
change, so its like:
  intial output
  changed output
  exit

With 2 seconds delay each time but that's not a big issue.

 - Craig
-- 
Craig Small VK2XLZ   http://enc.com.au/          csmall at : enc.com.au
Debian GNU/Linux     http://www.debian.org/      csmall at : debian.org
GPG fingerprint:     5D2F B320 B825 D939 04D2  0519 3938 F96B DF50 FEA5

diff --git a/watch.c b/watch.c
index 6ce174b..2afde1d 100644
--- a/watch.c
+++ b/watch.c
@@ -308,7 +308,6 @@ int main(int argc, char *argv[])
 
        int pipefd[2];
        int status;
-       int exit_early = 0;
        pid_t child;
 
        static struct option longopts[] = {
@@ -446,7 +445,7 @@ int main(int argc, char *argv[])
        if (precise_timekeeping)
                next_loop = get_time_usec();
 
-       do {
+       while (1) {
                time_t t = time(NULL);
                char *ts = ctime(&t);
                int tsl = strlen(ts);
@@ -581,6 +580,7 @@ int main(int argc, char *argv[])
                if ((p = fdopen(pipefd[0], "r")) == NULL)
                        xerr(5, _("fdopen"));
 
+               int exit_early = 0;
                for (y = show_title; y < height; y++) {
                        int eolseen = 0, tabpending = 0;
 #ifdef WITH_WATCH8BIT
@@ -730,6 +730,10 @@ int main(int argc, char *argv[])
                }
                first_screen = 0;
                refresh();
+
+               if (exit_early)
+                       break;
+
                if (precise_timekeeping) {
                        watch_usec_t cur_time = get_time_usec();
                        next_loop += USECS_PER_SEC * interval;
@@ -737,7 +741,7 @@ int main(int argc, char *argv[])
                                usleep(next_loop - cur_time);
                } else
                        usleep(interval * 1000000);
-       } while (!exit_early);
+       }
 
        endwin();
 

Other related posts: