Changeset eb522e8 in mainline for uspace/app/getterm/getterm.c
- Timestamp:
- 2011-06-01T08:43:42Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8d6c1f1
- Parents:
- 9e2e715 (diff), e51a514 (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
r9e2e715 reb522e8 43 43 #include <errno.h> 44 44 #include "version.h" 45 #include "welcome.h" 45 46 46 47 #define APP_NAME "getterm" … … 48 49 static void usage(void) 49 50 { 50 printf("Usage: %s <terminal> <path>\n", APP_NAME);51 printf("Usage: %s <terminal> [-w] <command> [<arguments...>]\n", APP_NAME); 51 52 } 52 53 … … 73 74 } 74 75 75 static task_id_t spawn(const char *fname)76 {77 task_id_t id;78 int rc;79 80 rc = task_spawnl(&id, fname, fname, NULL);81 if (rc != EOK) {82 printf("%s: Error spawning %s (%s)\n", APP_NAME, fname,83 str_error(rc));84 return 0;85 }86 87 return id;88 }89 90 76 int main(int argc, char *argv[]) 91 77 { 92 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) { 93 89 usage(); 94 90 return -1; 95 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; 96 109 97 reopen(&stdin, 0, argv[1], O_RDONLY, "r");98 reopen(&stdout, 1, argv[1], O_WRONLY, "w");99 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"); 100 113 101 114 /* … … 114 127 return -4; 115 128 116 version_print( argv[1]);117 task_id_t id = spawn(argv[2]);118 119 if (id != 0) { 120 task_exit_t texit;121 int retval;122 task_wait(id, &texit, &retval);123 124 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; 125 138 } 126 127 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; 128 148 } 129 149
Note:
See TracChangeset
for help on using the changeset viewer.