Changes in uspace/lib/c/generic/task.c [a35b458:1b20da0] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/task.c
ra35b458 r1b20da0 55 55 task_id_t task_id; 56 56 (void) __SYSCALL1(SYS_TASK_GET_ID, (sysarg_t) &task_id); 57 57 58 58 return task_id; 59 59 #endif /* __32_BITS__ */ 60 60 61 61 #ifdef __64_BITS__ 62 62 return (task_id_t) __SYSCALL0(SYS_TASK_GET_ID); … … 74 74 { 75 75 assert(name); 76 76 77 77 return (errno_t) __SYSCALL2(SYS_TASK_SET_NAME, (sysarg_t) name, str_size(name)); 78 78 } … … 108 108 { 109 109 /* Send default files */ 110 110 111 111 int fd_stdin = -1; 112 112 int fd_stdout = -1; 113 113 int fd_stderr = -1; 114 114 115 115 if (stdin != NULL) { 116 116 (void) vfs_fhandle(stdin, &fd_stdin); 117 117 } 118 118 119 119 if (stdout != NULL) { 120 120 (void) vfs_fhandle(stdout, &fd_stdout); … … 124 124 (void) vfs_fhandle(stderr, &fd_stderr); 125 125 } 126 126 127 127 return task_spawnvf(id, wait, path, args, fd_stdin, fd_stdout, 128 128 fd_stderr); … … 153 153 if (ldr == NULL) 154 154 return EREFUSED; 155 155 156 156 bool wait_initialized = false; 157 157 158 158 /* Get task ID. */ 159 159 task_id_t task_id; … … 161 161 if (rc != EOK) 162 162 goto error; 163 163 164 164 /* Send spawner's current working directory. */ 165 165 rc = loader_set_cwd(ldr); 166 166 if (rc != EOK) 167 167 goto error; 168 168 169 169 /* Send program binary. */ 170 170 rc = loader_set_program_path(ldr, path); 171 171 if (rc != EOK) 172 172 goto error; 173 173 174 174 /* Send arguments. */ 175 175 rc = loader_set_args(ldr, args); 176 176 if (rc != EOK) 177 177 goto error; 178 178 179 179 /* Send files */ 180 180 int root = vfs_root(); … … 185 185 goto error; 186 186 } 187 187 188 188 if (fd_stdin >= 0) { 189 189 rc = loader_add_inbox(ldr, "stdin", fd_stdin); … … 191 191 goto error; 192 192 } 193 193 194 194 if (fd_stdout >= 0) { 195 195 rc = loader_add_inbox(ldr, "stdout", fd_stdout); … … 197 197 goto error; 198 198 } 199 199 200 200 if (fd_stderr >= 0) { 201 201 rc = loader_add_inbox(ldr, "stderr", fd_stderr); … … 203 203 goto error; 204 204 } 205 205 206 206 /* Load the program. */ 207 207 rc = loader_load_program(ldr); 208 208 if (rc != EOK) 209 209 goto error; 210 210 211 211 /* Setup waiting for return value if needed */ 212 212 if (wait) { … … 216 216 wait_initialized = true; 217 217 } 218 218 219 219 /* Run it. */ 220 220 rc = loader_run(ldr); 221 221 if (rc != EOK) 222 222 goto error; 223 223 224 224 /* Success */ 225 225 if (id != NULL) 226 226 *id = task_id; 227 227 228 228 return EOK; 229 229 230 230 error: 231 231 if (wait_initialized) 232 232 task_cancel_wait(wait); 233 233 234 234 /* Error exit */ 235 235 loader_abort(ldr); … … 259 259 if (arglist == NULL) 260 260 return ENOMEM; 261 261 262 262 /* Fill in arguments. */ 263 263 const char *arg; … … 267 267 arglist[cnt++] = arg; 268 268 } while (arg != NULL); 269 269 270 270 /* Spawn task. */ 271 271 errno_t rc = task_spawnv(task_id, wait, path, arglist); 272 272 273 273 /* Free argument list. */ 274 274 free(arglist); … … 293 293 { 294 294 /* Count the number of arguments. */ 295 295 296 296 va_list ap; 297 297 const char *arg; 298 298 int cnt = 0; 299 299 300 300 va_start(ap, path); 301 301 do { … … 304 304 } while (arg != NULL); 305 305 va_end(ap); 306 306 307 307 va_start(ap, path); 308 308 errno_t rc = task_spawn(task_id, wait, path, cnt, ap); 309 309 va_end(ap); 310 310 311 311 return rc; 312 312 } … … 400 400 if (rc != EOK) 401 401 return rc; 402 402 403 403 return task_wait(&wait, texit, retval); 404 404 } … … 413 413 errno_t rc = (errno_t) async_req_1_0(exch, NS_RETVAL, val); 414 414 async_exchange_end(exch); 415 415 416 416 return rc; 417 417 }
Note:
See TracChangeset
for help on using the changeset viewer.