Changes in uspace/lib/c/generic/task.c [2443ad8:fafb8e5] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/task.c
r2443ad8 rfafb8e5 35 35 */ 36 36 37 #include <async.h>38 37 #include <task.h> 39 38 #include <loader/loader.h> … … 47 46 #include <ns.h> 48 47 #include <stdlib.h> 49 #include <udebug.h>50 48 #include <libc.h> 51 49 #include "private/ns.h" … … 96 94 * This is really just a convenience wrapper over the more complicated 97 95 * loader API. Arguments are passed as a null-terminated array of strings. 98 * A debug session is created optionally.99 96 * 100 97 * @param id If not NULL, the ID of the task is stored here on success. … … 103 100 * @param path Pathname of the binary to execute. 104 101 * @param argv Command-line arguments. 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) 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[]) 113 108 { 114 109 /* Send default files */ … … 130 125 } 131 126 132 return task_spawnvf _debug(id, wait, path, args, fd_stdin, fd_stdout,133 fd_stderr , rsess);127 return task_spawnvf(id, wait, path, args, fd_stdin, fd_stdout, 128 fd_stderr); 134 129 } 135 130 136 131 /** Create a new task by running an executable from the filesystem. 137 *138 * This is really just a convenience wrapper over the more complicated139 * 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 store143 * 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.157 132 * 158 133 * This is really just a convenience wrapper over the more complicated 159 134 * loader API. Arguments are passed as a null-terminated array of strings. 160 135 * Files are passed as null-terminated array of pointers to fdi_node_t. 161 * A debug session is created optionally.162 136 * 163 137 * @param id If not NULL, the ID of the task is stored here on success. 164 * @param wait If not NULL, setup waiting for task's return value and store .138 * @param wait If not NULL, setup waiting for task's return value and store 165 139 * @param path Pathname of the binary to execute. 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 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 { 182 151 /* Connect to a program loader. */ 183 152 loader_t *ldr = loader_connect(); … … 248 217 } 249 218 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 } 219 /* Run it. */ 220 rc = loader_run(ldr); 221 if (rc != EOK) 222 goto error; 274 223 275 224 /* Success */ 276 225 if (id != NULL) 277 226 *id = task_id; 278 if (rsess != NULL) 279 *rsess = ksess; 227 280 228 return EOK; 281 229 282 230 error: 283 if (ksess != NULL)284 async_hangup(ksess);285 231 if (wait_initialized) 286 232 task_cancel_wait(wait); … … 289 235 loader_abort(ldr); 290 236 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 execute301 * @param argv Command-line arguments302 * @param std_in File to use as stdin303 * @param std_out File to use as stdout304 * @param std_err File to use as stderr305 *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);314 237 } 315 238
Note:
See TracChangeset
for help on using the changeset viewer.