comparison libcommon/exit.c @ 54:812779459ddd

Calypso exit mode: show any output from back end
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 21 Mar 2021 20:58:20 +0000
parents c9ef9e91dd8e
children
comparison
equal deleted inserted replaced
53:fbedb67d234f 54:812779459ddd
2 #include <stdlib.h> 2 #include <stdlib.h>
3 #include <string.h> 3 #include <string.h>
4 #include <strings.h> 4 #include <strings.h>
5 5
6 extern unsigned calypso_fd; 6 extern unsigned calypso_fd;
7 extern FILE *cpipeF; 7 extern FILE *cpipeF, *rpipeF;
8
9 calypso_poweroff()
10 {
11 int c;
12
13 fputs("poweroff\n", cpipeF);
14 fflush(cpipeF);
15 while ((c = getc(rpipeF)) != EOF)
16 putchar(c);
17 exit(0);
18 }
8 19
9 good_exit() 20 good_exit()
10 { 21 {
11 if (calypso_fd) { 22 if (calypso_fd)
12 fputs("poweroff\n", cpipeF); 23 calypso_poweroff();
13 fflush(cpipeF);
14 }
15 exit(0); 24 exit(0);
16 } 25 }
17 26
18 cmd_exit(argc, argv) 27 cmd_exit(argc, argv)
19 char **argv; 28 char **argv;
25 "error: exit arguments are only meaningful with Calypso back end\n"); 34 "error: exit arguments are only meaningful with Calypso back end\n");
26 return(-1); 35 return(-1);
27 } 36 }
28 if (!strcmp(argv[1], "bare")) 37 if (!strcmp(argv[1], "bare"))
29 exit(0); 38 exit(0);
30 if (!strcmp(argv[1], "iota-off")) { 39 if (!strcmp(argv[1], "iota-off"))
31 fputs("poweroff\n", cpipeF); 40 calypso_poweroff();
32 fflush(cpipeF);
33 exit(0);
34 }
35 fprintf(stderr, "error: \"%s\" is not an understood exit mode\n", 41 fprintf(stderr, "error: \"%s\" is not an understood exit mode\n",
36 argv[1]); 42 argv[1]);
37 return(-1); 43 return(-1);
38 } 44 }