Changes in uspace/app/getterm/getterm.c [dd567c6:d9fae235] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/getterm/getterm.c
rdd567c6 rd9fae235 41 41 #include <task.h> 42 42 #include <str_error.h> 43 #include <errno.h>44 43 #include "version.h" 45 #include "welcome.h"46 44 47 45 #define APP_NAME "getterm" … … 49 47 static void usage(void) 50 48 { 51 printf("Usage: %s <terminal> [-w] <command> [<arguments...>]\n", APP_NAME);49 printf("Usage: %s <terminal> <path>\n", APP_NAME); 52 50 } 53 51 … … 74 72 } 75 73 74 static task_id_t spawn(const char *fname) 75 { 76 const char *args[2]; 77 78 args[0] = fname; 79 args[1] = NULL; 80 81 int err; 82 task_id_t id = task_spawn(fname, args, &err); 83 84 if (id == 0) 85 printf("%s: Error spawning %s (%s)\n", APP_NAME, fname, 86 str_error(err)); 87 88 return id; 89 } 90 76 91 int main(int argc, char *argv[]) 77 92 { 78 int rc; 79 task_exit_t texit; 80 int retval; 81 task_id_t id; 82 char *fname, *term; 83 char **cmd_args; 84 bool print_wmsg; 85 86 argv++; 87 argc--; 88 if (argc < 1) { 93 if (argc < 3) { 89 94 usage(); 90 95 return -1; 91 96 } 92 93 if (str_cmp(*argv, "-w") == 0) {94 print_wmsg = true;95 argv++;96 argc--;97 } else {98 print_wmsg = false;99 }100 101 if (argc < 2) {102 usage();103 return -1;104 }105 106 term = *argv++;107 fname = *argv;108 cmd_args = argv;109 97 110 reopen(&stdin, 0, term, O_RDONLY, "r");111 reopen(&stdout, 1, term, O_WRONLY, "w");112 reopen(&stderr, 2, term, O_WRONLY, "w");98 reopen(&stdin, 0, argv[1], O_RDONLY, "r"); 99 reopen(&stdout, 1, argv[1], O_WRONLY, "w"); 100 reopen(&stderr, 2, argv[1], O_WRONLY, "w"); 113 101 114 102 /* … … 127 115 return -4; 128 116 129 version_print( term);130 if (print_wmsg)131 welcome_msg_print();132 133 rc = task_spawnv(&id, fname, (const char * const *) cmd_args);134 if (rc != EOK) {135 printf("%s: Error spawning %s (%s)\n", APP_NAME, fname,136 str_error(rc));137 return -5;117 version_print(argv[1]); 118 task_id_t id = spawn(argv[2]); 119 120 if (id != 0) { 121 task_exit_t texit; 122 int retval; 123 task_wait(id, &texit, &retval); 124 125 return 0; 138 126 } 139 140 rc = task_wait(id, &texit, &retval); 141 if (rc != EOK) { 142 printf("%s: Error waiting for %s (%s)\n", APP_NAME, fname, 143 str_error(rc)); 144 return -6; 145 } 146 147 return 0; 127 128 return -5; 148 129 } 149 130
Note:
See TracChangeset
for help on using the changeset viewer.