Changeset 5e718d9 in mainline for uspace/lib/c/generic/task.c


Ignore:
Timestamp:
2012-08-21T10:04:16Z (12 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
67edca6
Parents:
0da6c04 (diff), 6a97f2e (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.
Message:

Merge with upstream (lp:~wtachi/helenos/bithenge)

File:
1 edited

Legend:

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

    r0da6c04 r5e718d9  
    201201 *
    202202 * This is really just a convenience wrapper over the more complicated
     203 * loader API. Arguments are passed in a va_list.
     204 *
     205 * @param id   If not NULL, the ID of the task is stored here on success.
     206 * @param path Pathname of the binary to execute.
     207 * @param cnt  Number of arguments.
     208 * @param ap   Command-line arguments.
     209 *
     210 * @return Zero on success or negative error code.
     211 *
     212 */
     213int task_spawn(task_id_t *task_id, const char *path, int cnt, va_list ap)
     214{
     215        /* Allocate argument list. */
     216        const char **arglist = malloc(cnt * sizeof(const char *));
     217        if (arglist == NULL)
     218                return ENOMEM;
     219       
     220        /* Fill in arguments. */
     221        const char *arg;
     222        cnt = 0;
     223        do {
     224                arg = va_arg(ap, const char *);
     225                arglist[cnt++] = arg;
     226        } while (arg != NULL);
     227       
     228        /* Spawn task. */
     229        int rc = task_spawnv(task_id, path, arglist);
     230       
     231        /* Free argument list. */
     232        free(arglist);
     233        return rc;
     234}
     235
     236/** Create a new task by running an executable from the filesystem.
     237 *
     238 * This is really just a convenience wrapper over the more complicated
    203239 * loader API. Arguments are passed as a null-terminated list of arguments.
    204240 *
     
    216252        va_list ap;
    217253        const char *arg;
    218         const char **arglist;
    219254        int cnt = 0;
    220255       
     
    226261        va_end(ap);
    227262       
    228         /* Allocate argument list. */
    229         arglist = malloc(cnt * sizeof(const char *));
    230         if (arglist == NULL)
    231                 return ENOMEM;
    232        
    233         /* Fill in arguments. */
    234         cnt = 0;
    235263        va_start(ap, path);
    236         do {
    237                 arg = va_arg(ap, const char *);
    238                 arglist[cnt++] = arg;
    239         } while (arg != NULL);
     264        int rc = task_spawn(task_id, path, cnt, ap);
    240265        va_end(ap);
    241266       
    242         /* Spawn task. */
    243         int rc = task_spawnv(task_id, path, arglist);
    244        
    245         /* Free argument list. */
    246         free(arglist);
    247267        return rc;
    248268}
Note: See TracChangeset for help on using the changeset viewer.