Skip to content

Commit

Permalink
[ui] Allow Ctrl-C to cancel wait for net device link-up
Browse files Browse the repository at this point in the history
This really ought to be handled via monojob.c and the usual Ctrl-C
mechanism that handles cancelling DHCP or file downloads.
  • Loading branch information
Michael Brown committed Jan 27, 2009
1 parent d10a7e7 commit 52c596b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/usr/ifmgmt.c
Expand Up @@ -20,9 +20,11 @@
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <console.h>
#include <gpxe/netdevice.h>
#include <gpxe/device.h>
#include <gpxe/process.h>
#include <gpxe/keys.h>
#include <usr/ifmgmt.h>

/** @file
Expand Down Expand Up @@ -101,12 +103,19 @@ void ifstat ( struct net_device *netdev ) {
* @v max_wait_ms Maximum time to wait, in ms
*/
int iflinkwait ( struct net_device *netdev, unsigned int max_wait_ms ) {
int key;

while ( 1 ) {
if ( netdev_link_ok ( netdev ) )
return 0;
if ( max_wait_ms-- == 0 )
return -ETIMEDOUT;
step();
if ( iskey() ) {
key = getchar();
if ( key == CTRL_C )
return -ECANCELED;
}
mdelay ( 1 );
}
}

0 comments on commit 52c596b

Please sign in to comment.