Hi ,

I use busybox version 1.16.1.
I have two processes that have to be running all the time, but with some
differences in behavior.

process 1: This process must be up and running all the time, but need
not be re-run every now and then. All I need is to ensure this process
exits, its automatically re-run.

process 2: this process has a life span of about 20 seconds. So, I need
to make sure every 20 sec, this is run. This process exits
automatically.

In the second case, I use "watch -t -n 25 process2" and that serves my
purpose.
But how do I achieve the process 1 functionality?

BTW, I made a small change in watch.c when -t option is used.

orig code:

        if (!(opt & 0x2)) { // no -t 
            const unsigned time_len = sizeof("1234-67-90 23:56:89");
            time_t t;

            // STDERR_FILENO is procps3 compat:
            // "watch ls 2>/dev/null" does not detect tty size
            get_terminal_width_height(STDERR_FILENO, &new_width, NULL);
            if (new_width != width) {
                width = new_width;
                free(header);
                header = xasprintf("Every %us: %-*s", period,
(int)width, cmd);
            }   
            time(&t);
            if (time_len < width)
                strftime(header + width - time_len, time_len,
                    "%Y-%m-%d %H:%M:%S", localtime(&t));

            // compat: empty line between header and cmd output
            printf("%s\n\n", header);
        }   
        fflush_all();

my change: 

    move the fflush_all() into the if condition like this:

        if (!(opt & 0x2)) { // no -t 
            const unsigned time_len = sizeof("1234-67-90 23:56:89");
            time_t t;
            fflush_all();
....
.....
        }

The user specifies the -t option only if he wants to do the "watch"
silently. if the screen refreshes every often, does not look nice.

Comments welcome.

Murali
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to