Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/task.c

    r2443ad8 rfafb8e5  
    3535 */
    3636
    37 #include <async.h>
    3837#include <task.h>
    3938#include <loader/loader.h>
     
    4746#include <ns.h>
    4847#include <stdlib.h>
    49 #include <udebug.h>
    5048#include <libc.h>
    5149#include "private/ns.h"
     
    9694 * This is really just a convenience wrapper over the more complicated
    9795 * loader API. Arguments are passed as a null-terminated array of strings.
    98  * A debug session is created optionally.
    9996 *
    10097 * @param id   If not NULL, the ID of the task is stored here on success.
     
    103100 * @param path Pathname of the binary to execute.
    104101 * @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 */
     106errno_t task_spawnv(task_id_t *id, task_wait_t *wait, const char *path,
     107    const char *const args[])
    113108{
    114109        /* Send default files */
     
    130125        }
    131126
    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);
    134129}
    135130
    136131/** 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.
    157132 *
    158133 * This is really just a convenience wrapper over the more complicated
    159134 * loader API. Arguments are passed as a null-terminated array of strings.
    160135 * Files are passed as null-terminated array of pointers to fdi_node_t.
    161  * A debug session is created optionally.
    162136 *
    163137 * @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
    165139 * @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 */
     148errno_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{
    182151        /* Connect to a program loader. */
    183152        loader_t *ldr = loader_connect();
     
    248217        }
    249218
    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;
    274223
    275224        /* Success */
    276225        if (id != NULL)
    277226                *id = task_id;
    278         if (rsess != NULL)
    279                 *rsess = ksess;
     227
    280228        return EOK;
    281229
    282230error:
    283         if (ksess != NULL)
    284                 async_hangup(ksess);
    285231        if (wait_initialized)
    286232                task_cancel_wait(wait);
     
    289235        loader_abort(ldr);
    290236        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);
    314237}
    315238
Note: See TracChangeset for help on using the changeset viewer.