Skip to content

Commit

Permalink
[ui] Add progress dots while waiting on any foreground job
Browse files Browse the repository at this point in the history
Print one dot per second while waiting in monojob.c (e.g. for DHCP,
for file downloads, etc.), to inform user that the system has not
locked up.

Patch contributed by Andrew Schran <aschran@google.com>, minor
modification by me.
  • Loading branch information
Michael Brown committed Jul 24, 2008
1 parent 764e2cc commit 702e0be
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/core/monojob.c
Expand Up @@ -24,6 +24,7 @@
#include <gpxe/keys.h>
#include <gpxe/job.h>
#include <gpxe/monojob.h>
#include <gpxe/timer.h>

/** @file
*
Expand Down Expand Up @@ -62,9 +63,11 @@ struct job_interface monojob = {
int monojob_wait ( const char *string ) {
int key;
int rc;
tick_t last_progress_dot;

printf ( "%s... ", string );
printf ( "%s.", string );
monojob_rc = -EINPROGRESS;
last_progress_dot = currticks();
while ( monojob_rc == -EINPROGRESS ) {
step();
if ( iskey() ) {
Expand All @@ -78,14 +81,18 @@ int monojob_wait ( const char *string ) {
break;
}
}
if ( ( currticks() - last_progress_dot ) > TICKS_PER_SEC ) {
printf ( "." );
last_progress_dot = currticks();
}
}
rc = monojob_rc;

done:
if ( rc ) {
printf ( "%s\n", strerror ( rc ) );
printf ( " %s\n", strerror ( rc ) );
} else {
printf ( "ok\n" );
printf ( " ok\n" );
}
return rc;
}

0 comments on commit 702e0be

Please sign in to comment.