Changeset 0b749a3 in mainline for uspace/app/getterm/getterm.c
- Timestamp:
- 2010-11-22T15:39:53Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0eddb76, aae339e9
- Parents:
- 9a1d8ab (diff), 8cd1aa5e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/getterm/getterm.c
r9a1d8ab r0b749a3 41 41 #include <task.h> 42 42 #include <str_error.h> 43 #include <errno.h> 43 44 #include "version.h" 45 #include "welcome.h" 44 46 45 47 #define APP_NAME "getterm" … … 47 49 static void usage(void) 48 50 { 49 printf("Usage: %s <terminal> <path>\n", APP_NAME);51 printf("Usage: %s <terminal> [-w] <command> [<arguments...>]\n", APP_NAME); 50 52 } 51 53 … … 72 74 } 73 75 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 91 76 int main(int argc, char *argv[]) 92 77 { 93 if (argc < 3) { 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) { 94 89 usage(); 95 90 return -1; 96 91 } 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; 97 109 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");110 reopen(&stdin, 0, term, O_RDONLY, "r"); 111 reopen(&stdout, 1, term, O_WRONLY, "w"); 112 reopen(&stderr, 2, term, O_WRONLY, "w"); 101 113 102 114 /* … … 115 127 return -4; 116 128 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;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; 126 138 } 127 128 return -5; 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; 129 148 } 130 149
Note:
See TracChangeset
for help on using the changeset viewer.