Changeset 84876aa4 in mainline for uspace/lib/c/generic/task.c
- Timestamp:
- 2019-11-15T13:46:34Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ecb7828
- Parents:
- b093a62 (diff), d548fc0 (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/lib/c/generic/task.c
rb093a62 r84876aa4 35 35 */ 36 36 37 #include <async.h> 37 38 #include <task.h> 38 39 #include <loader/loader.h> … … 46 47 #include <ns.h> 47 48 #include <stdlib.h> 49 #include <udebug.h> 48 50 #include <libc.h> 49 51 #include "private/ns.h" … … 94 96 * This is really just a convenience wrapper over the more complicated 95 97 * loader API. Arguments are passed as a null-terminated array of strings. 98 * A debug session is created optionally. 96 99 * 97 100 * @param id If not NULL, the ID of the task is stored here on success. … … 100 103 * @param path Pathname of the binary to execute. 101 104 * @param argv Command-line arguments. 102 * 103 * @return Zero on success or an error code. 104 * 105 */ 106 errno_t task_spawnv(task_id_t *id, task_wait_t *wait, const char *path, 107 const char *const args[]) 105 * @param rsess Place to store pointer to debug session or @c NULL 106 * not to start a debug session 107 * 108 * @return Zero on success or an error code. 109 * 110 */ 111 errno_t task_spawnv_debug(task_id_t *id, task_wait_t *wait, const char *path, 112 const char *const args[], async_sess_t **rsess) 108 113 { 109 114 /* Send default files */ … … 125 130 } 126 131 127 return task_spawnvf (id, wait, path, args, fd_stdin, fd_stdout,128 fd_stderr );132 return task_spawnvf_debug(id, wait, path, args, fd_stdin, fd_stdout, 133 fd_stderr, rsess); 129 134 } 130 135 131 136 /** Create a new task by running an executable from the filesystem. 137 * 138 * This is really just a convenience wrapper over the more complicated 139 * loader API. Arguments are passed as a null-terminated array of strings. 140 * 141 * @param id If not NULL, the ID of the task is stored here on success. 142 * @param wait If not NULL, setup waiting for task's return value and store 143 * the information necessary for waiting here on success. 144 * @param path Pathname of the binary to execute. 145 * @param argv Command-line arguments. 146 * 147 * @return Zero on success or an error code. 148 * 149 */ 150 errno_t task_spawnv(task_id_t *id, task_wait_t *wait, const char *path, 151 const char *const args[]) 152 { 153 return task_spawnv_debug(id, wait, path, args, NULL); 154 } 155 156 /** Create a new task by loading an executable from the filesystem. 132 157 * 133 158 * This is really just a convenience wrapper over the more complicated 134 159 * loader API. Arguments are passed as a null-terminated array of strings. 135 160 * Files are passed as null-terminated array of pointers to fdi_node_t. 161 * A debug session is created optionally. 136 162 * 137 163 * @param id If not NULL, the ID of the task is stored here on success. 138 * @param wait If not NULL, setup waiting for task's return value and store 164 * @param wait If not NULL, setup waiting for task's return value and store. 139 165 * @param path Pathname of the binary to execute. 140 * @param argv Command-line arguments. 141 * @param std_in File to use as stdin. 142 * @param std_out File to use as stdout. 143 * @param std_err File to use as stderr. 144 * 145 * @return Zero on success or an error code. 146 * 147 */ 148 errno_t task_spawnvf(task_id_t *id, task_wait_t *wait, const char *path, 149 const char *const args[], int fd_stdin, int fd_stdout, int fd_stderr) 150 { 166 * @param argv Command-line arguments 167 * @param std_in File to use as stdin 168 * @param std_out File to use as stdout 169 * @param std_err File to use as stderr 170 * @param rsess Place to store pointer to debug session or @c NULL 171 * not to start a debug session 172 * 173 * @return Zero on success or an error code 174 * 175 */ 176 errno_t task_spawnvf_debug(task_id_t *id, task_wait_t *wait, 177 const char *path, const char *const args[], int fd_stdin, int fd_stdout, 178 int fd_stderr, async_sess_t **rsess) 179 { 180 async_sess_t *ksess = NULL; 181 151 182 /* Connect to a program loader. */ 152 183 loader_t *ldr = loader_connect(); … … 217 248 } 218 249 219 /* Run it. */ 220 rc = loader_run(ldr); 221 if (rc != EOK) 222 goto error; 250 /* Start a debug session if requested */ 251 if (rsess != NULL) { 252 ksess = async_connect_kbox(task_id); 253 if (ksess == NULL) { 254 /* Most likely debugging support is not compiled in */ 255 rc = ENOTSUP; 256 goto error; 257 } 258 259 rc = udebug_begin(ksess); 260 if (rc != EOK) 261 goto error; 262 263 /* 264 * Run it, not waiting for response. It would never come 265 * as the loader is stopped. 266 */ 267 loader_run_nowait(ldr); 268 } else { 269 /* Run it. */ 270 rc = loader_run(ldr); 271 if (rc != EOK) 272 goto error; 273 } 223 274 224 275 /* Success */ 225 276 if (id != NULL) 226 277 *id = task_id; 227 278 if (rsess != NULL) 279 *rsess = ksess; 228 280 return EOK; 229 281 230 282 error: 283 if (ksess != NULL) 284 async_hangup(ksess); 231 285 if (wait_initialized) 232 286 task_cancel_wait(wait); … … 235 289 loader_abort(ldr); 236 290 return rc; 291 } 292 293 /** Create a new task by running an executable from the filesystem. 294 * 295 * Arguments are passed as a null-terminated array of strings. 296 * Files are passed as null-terminated array of pointers to fdi_node_t. 297 * 298 * @param id If not NULL, the ID of the task is stored here on success. 299 * @param wait If not NULL, setup waiting for task's return value and store. 300 * @param path Pathname of the binary to execute 301 * @param argv Command-line arguments 302 * @param std_in File to use as stdin 303 * @param std_out File to use as stdout 304 * @param std_err File to use as stderr 305 * 306 * @return Zero on success or an error code. 307 * 308 */ 309 errno_t task_spawnvf(task_id_t *id, task_wait_t *wait, const char *path, 310 const char *const args[], int fd_stdin, int fd_stdout, int fd_stderr) 311 { 312 return task_spawnvf_debug(id, wait, path, args, fd_stdin, fd_stdout, 313 fd_stderr, NULL); 237 314 } 238 315
Note:
See TracChangeset
for help on using the changeset viewer.