Parcourir la source

[ui] Allow Ctrl-C to cancel wait for net device link-up

This really ought to be handled via monojob.c and the usual Ctrl-C
mechanism that handles cancelling DHCP or file downloads.
tags/v0.9.7
Michael Brown il y a 16 ans
Parent
révision
52c596bafb
1 fichiers modifiés avec 9 ajouts et 0 suppressions
  1. 9
    0
      src/usr/ifmgmt.c

+ 9
- 0
src/usr/ifmgmt.c Voir le fichier

@@ -20,9 +20,11 @@
20 20
 #include <stdio.h>
21 21
 #include <unistd.h>
22 22
 #include <errno.h>
23
+#include <console.h>
23 24
 #include <gpxe/netdevice.h>
24 25
 #include <gpxe/device.h>
25 26
 #include <gpxe/process.h>
27
+#include <gpxe/keys.h>
26 28
 #include <usr/ifmgmt.h>
27 29
 
28 30
 /** @file
@@ -101,12 +103,19 @@ void ifstat ( struct net_device *netdev ) {
101 103
  * @v max_wait_ms	Maximum time to wait, in ms
102 104
  */
103 105
 int iflinkwait ( struct net_device *netdev, unsigned int max_wait_ms ) {
106
+	int key;
107
+
104 108
 	while ( 1 ) {
105 109
 		if ( netdev_link_ok ( netdev ) )
106 110
 			return 0;
107 111
 		if ( max_wait_ms-- == 0 )
108 112
 			return -ETIMEDOUT;
109 113
 		step();
114
+		if ( iskey() ) {
115
+			key = getchar();
116
+			if ( key == CTRL_C )
117
+				return -ECANCELED;
118
+		}
110 119
 		mdelay ( 1 );
111 120
 	}
112 121
 }

Chargement…
Annuler
Enregistrer