[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT/HELLOWORLD PATCH] Add option to stay alive



Adds an option that does not shutdown the guest. When the boot process
is done, an ASCII animation of a swimming fish is shown. This option
can be useful (and entertaining) for demo purposes. The example can
also be handy to test initial ports to new platforms or libcs.

Signed-off-by: Simon Kuenzer <simon.kuenzer@xxxxxxxxx>
---
 Config.uk |  7 +++++++
 main.c    | 34 ++++++++++++++++++++++++++++++++--
 2 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/Config.uk b/Config.uk
index 5e25d05..56cea87 100644
--- a/Config.uk
+++ b/Config.uk
@@ -10,3 +10,10 @@ config APPHELLOWORLD_PRINTARGS
        default y
        help
          Prints argument list (argv) to stdout
+
+config APPHELLOWORLD_SPINNER
+       bool "Stay alive"
+       select LIBUKTIME
+       default n
+       help
+         Shows an animation instead of shutting down
diff --git a/main.c b/main.c
index 6afa19e..c442058 100644
--- a/main.c
+++ b/main.c
@@ -1,18 +1,48 @@
 #include <stdio.h>
+#include <unistd.h>
+#include <uk/essentials.h>
 
 /* Import user configuration: */
 #include <uk/config.h>
 
+#if CONFIG_APPHELLOWORLD_SPINNER
+static const char *spinner[] = {
+       ">))'>        ",
+       " >))'>       ",
+       "  >))'>      ",
+       "   >))'>     ",
+       "    >))'o    ",
+       "     >))'>°  ",
+       "     <'((< ° ",
+       "    <'((<   '",
+       "   <'((<     ",
+       "  <'((<      ",
+       " <'((<       ",
+       "<'((<        ",
+};
+#endif
+
 int main(int argc, char *argv[])
 {
+#if CONFIG_APPHELLOWORLD_PRINTARGS || CONFIG_APPHELLOWORLD_SPINNER
+       int i;
+#endif
        printf("Hello world!\n");
 
 #if CONFIG_APPHELLOWORLD_PRINTARGS
-       int i;
-
        printf("Arguments: ");
        for (i=0; i<argc; ++i)
                printf(" \"%s\"", argv[i]);
        printf("\n");
 #endif
+
+#if CONFIG_APPHELLOWORLD_SPINNER
+       i = 0;
+       printf("\n");
+       while (1) {
+               i %= ARRAY_SIZE(spinner);
+               printf("\r%s", spinner[i++]);
+               sleep(1);
+       }
+#endif
 }
-- 
2.20.1


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.