Changeset 1c635d6 in mainline


Ignore:
Timestamp:
2014-08-26T15:12:12Z (10 years ago)
Author:
Martin Sucha <sucha14@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
613d644
Parents:
df7f5cea
Message:

Do not hold a task's return value after it has disconnected.

Holding the task's return value meant that if nobody waited
for task's result, it polluted NS's memory. This was apparently
done because of a race between spawning a task and waiting for it.

We solve this problem in another way: ns discards the return value
as soon as the task disconnects from it. This typically happens
when the task finishes its execution. In order to avoid the race,
we send the wait request to ns while spawning the task (i.e. when
we talk to the loader), but before we allow the loaded program
to run.

Fixes #132

Location:
uspace
Files:
1 added
32 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/exec.c

    rdf7f5cea r1c635d6  
    9797{
    9898        task_id_t tid;
     99        task_wait_t twait;
    99100        task_exit_t texit;
    100101        char *tmp;
     
    121122        file_handles_p[i] = NULL;
    122123
    123         rc = task_spawnvf(&tid, tmp, (const char **) argv, file_handles_p);
     124        rc = task_spawnvf(&tid, &twait, tmp, (const char **) argv, file_handles_p);
    124125        free(tmp);
    125126
     
    130131        }
    131132       
    132         rc = task_wait(tid, &texit, &retval);
     133        rc = task_wait(&twait, &texit, &retval);
    133134        if (rc != EOK) {
    134135                printf("%s: Failed waiting for command (%s)\n", progname,
  • uspace/app/getterm/getterm.c

    rdf7f5cea r1c635d6  
    165165       
    166166        task_id_t id;
     167        task_wait_t twait;
    167168       
    168         int rc = task_spawnv(&id, cmd, (const char * const *) args);
     169        int rc = task_spawnv(&id, &twait, cmd, (const char * const *) args);
    169170        if (rc != EOK) {
    170171                printf("%s: Error spawning %s (%s)\n", APP_NAME, cmd,
     
    175176        task_exit_t texit;
    176177        int retval;
    177         rc = task_wait(id, &texit, &retval);
     178        rc = task_wait(&twait, &texit, &retval);
    178179        if (rc != EOK) {
    179180                printf("%s: Error waiting for %s (%s)\n", APP_NAME, cmd,
  • uspace/app/init/init.c

    rdf7f5cea r1c635d6  
    172172        va_start(ap, path);
    173173        task_id_t id;
    174         int rc = task_spawn(&id, path, cnt, ap);
     174        task_wait_t wait;
     175        int rc = task_spawn(&id, &wait, path, cnt, ap);
    175176        va_end(ap);
    176177       
     
    189190        task_exit_t texit;
    190191        int retval;
    191         rc = task_wait(id, &texit, &retval);
     192        rc = task_wait(&wait, &texit, &retval);
    192193        if (rc != EOK) {
    193194                printf("%s: Error waiting for %s (%s)\n", NAME, path,
     
    253254       
    254255        task_id_t id;
    255         int rc = task_spawnl(&id, app, app, winreg, NULL);
     256        task_wait_t wait;
     257        int rc = task_spawnl(&id, &wait, app, app, winreg, NULL);
    256258        if (rc != EOK) {
    257259                printf("%s: Error spawning %s %s (%s)\n", NAME, app,
     
    262264        task_exit_t texit;
    263265        int retval;
    264         rc = task_wait(id, &texit, &retval);
     266        rc = task_wait(&wait, &texit, &retval);
    265267        if ((rc != EOK) || (texit != TASK_EXIT_NORMAL)) {
    266268                printf("%s: Error retrieving retval from %s (%s)\n", NAME,
     
    278280                    APP_GETTERM, svc, LOCFS_MOUNT_POINT, app);
    279281               
    280                 int rc = task_spawnl(NULL, APP_GETTERM, APP_GETTERM, svc,
     282                int rc = task_spawnl(NULL, NULL, APP_GETTERM, APP_GETTERM, svc,
    281283                    LOCFS_MOUNT_POINT, "--msg", "--wait", "--", app, NULL);
    282284                if (rc != EOK)
     
    287289                    APP_GETTERM, svc, LOCFS_MOUNT_POINT, app);
    288290               
    289                 int rc = task_spawnl(NULL, APP_GETTERM, APP_GETTERM, svc,
     291                int rc = task_spawnl(NULL, NULL, APP_GETTERM, APP_GETTERM, svc,
    290292                    LOCFS_MOUNT_POINT, "--wait", "--", app, NULL);
    291293                if (rc != EOK)
  • uspace/app/redir/redir.c

    rdf7f5cea r1c635d6  
    7575}
    7676
    77 static task_id_t spawn(int argc, char *argv[])
     77static task_id_t spawn(task_wait_t *wait, int argc, char *argv[])
    7878{
    7979        const char **args;
     
    9393        args[argc] = NULL;
    9494       
    95         rc = task_spawnv(&id, argv[0], args);
     95        rc = task_spawnv(&id, wait, argv[0], args);
    9696       
    9797        free(args);
     
    152152         */
    153153        setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
    154        
    155         task_id_t id = spawn(argc - i, argv + i);
     154
     155        task_wait_t wait;       
     156        task_id_t id = spawn(&wait, argc - i, argv + i);
    156157       
    157158        if (id != 0) {
    158159                task_exit_t texit;
    159160                int retval;
    160                 task_wait(id, &texit, &retval);
     161                task_wait(&wait, &texit, &retval);
    161162               
    162163                return retval;
  • uspace/app/sbi/src/os/helenos.c

    rdf7f5cea r1c635d6  
    250250{
    251251        task_id_t tid;
     252        task_wait_t twait;
    252253        task_exit_t texit;
    253254        int rc, retval;
    254255
    255         rc = task_spawnv(&tid, cmd[0], (char const * const *) cmd);
     256        rc = task_spawnv(&tid, &twait, cmd[0], (char const * const *) cmd);
    256257        if (rc != EOK) {
    257258                printf("Error: Failed spawning '%s' (%s).\n", cmd[0],
     
    261262
    262263        /* XXX Handle exit status and return value. */
    263         rc = task_wait(tid, &texit, &retval);
     264        rc = task_wait(&twait, &texit, &retval);
    264265        (void) rc;
    265266
  • uspace/app/trace/trace.c

    rdf7f5cea r1c635d6  
    876876                printf("Waiting for task to exit.\n");
    877877
    878                 rc = task_wait(task_id, &texit, &retval);
     878                rc = task_wait_task_id(task_id, &texit, &retval);
    879879                if (rc != EOK) {
    880880                        printf("Failed waiting for task.\n");
  • uspace/app/viewer/viewer.c

    rdf7f5cea r1c635d6  
    4444#include <surface.h>
    4545#include <codec/tga.h>
     46#include <task.h>
    4647
    4748#define NAME  "viewer"
  • uspace/app/vlaunch/vlaunch.c

    rdf7f5cea r1c635d6  
    9494       
    9595        task_id_t id;
    96         int rc = task_spawnl(&id, app, app, winreg, NULL);
     96        task_wait_t wait;
     97        int rc = task_spawnl(&id, &wait, app, app, winreg, NULL);
    9798        if (rc != EOK) {
    9899                printf("%s: Error spawning %s %s (%s)\n", NAME, app,
     
    103104        task_exit_t texit;
    104105        int retval;
    105         rc = task_wait(id, &texit, &retval);
     106        rc = task_wait(&wait, &texit, &retval);
    106107        if ((rc != EOK) || (texit != TASK_EXIT_NORMAL)) {
    107108                printf("%s: Error retrieving retval from %s (%s)\n", NAME,
  • uspace/lib/c/generic/task.c

    rdf7f5cea r1c635d6  
    22 * Copyright (c) 2006 Jakub Jermar
    33 * Copyright (c) 2008 Jiri Svoboda
     4 * Copyright (c) 2014 Martin Sucha
    45 * All rights reserved.
    56 *
     
    9495 *
    9596 * @param id   If not NULL, the ID of the task is stored here on success.
     97 * @param wait If not NULL, setup waiting for task's return value and store
     98 *             the information necessary for waiting here on success.
    9699 * @param path Pathname of the binary to execute.
    97100 * @param argv Command-line arguments.
     
    100103 *
    101104 */
    102 int task_spawnv(task_id_t *id, const char *path, const char *const args[])
     105int task_spawnv(task_id_t *id, task_wait_t *wait, const char *path,
     106    const char *const args[])
    103107{
    104108        /* Send default files */
     
    125129        files[3] = NULL;
    126130       
    127         return task_spawnvf(id, path, args, files);
     131        return task_spawnvf(id, wait, path, args, files);
    128132}
    129133
     
    135139 *
    136140 * @param id    If not NULL, the ID of the task is stored here on success.
     141 * @param wait  If not NULL, setup waiting for task's return value and store
     142 *              the information necessary for waiting here on success.
    137143 * @param path  Pathname of the binary to execute.
    138144 * @param argv  Command-line arguments.
     
    142148 *
    143149 */
    144 int task_spawnvf(task_id_t *id, const char *path, const char *const args[],
    145     int *const files[])
     150int task_spawnvf(task_id_t *id, task_wait_t *wait, const char *path,
     151    const char *const args[], int *const files[])
    146152{
    147153        /* Connect to a program loader. */
     
    150156                return EREFUSED;
    151157       
     158        bool wait_initialized = false;
     159       
    152160        /* Get task ID. */
    153161        task_id_t task_id;
     
    181189                goto error;
    182190       
     191        /* Setup waiting for return value if needed */
     192        if (wait) {
     193                rc = task_setup_wait(task_id, wait);
     194                if (rc != EOK)
     195                        goto error;
     196                wait_initialized = true;
     197        }
     198       
    183199        /* Run it. */
    184200        rc = loader_run(ldr);
     
    193209       
    194210error:
     211        if (wait_initialized)
     212                task_cancel_wait(wait);
     213       
    195214        /* Error exit */
    196215        loader_abort(ldr);
     
    204223 *
    205224 * @param id   If not NULL, the ID of the task is stored here on success.
     225 * @param wait If not NULL, setup waiting for task's return value and store
     226 *             the information necessary for waiting here on success.
    206227 * @param path Pathname of the binary to execute.
    207228 * @param cnt  Number of arguments.
     
    211232 *
    212233 */
    213 int task_spawn(task_id_t *task_id, const char *path, int cnt, va_list ap)
     234int task_spawn(task_id_t *task_id, task_wait_t *wait, const char *path,
     235    int cnt, va_list ap)
    214236{
    215237        /* Allocate argument list. */
     
    227249       
    228250        /* Spawn task. */
    229         int rc = task_spawnv(task_id, path, arglist);
     251        int rc = task_spawnv(task_id, wait, path, arglist);
    230252       
    231253        /* Free argument list. */
     
    240262 *
    241263 * @param id   If not NULL, the ID of the task is stored here on success.
     264 * @param wait If not NULL, setup waiting for task's return value and store
     265 *             the information necessary for waiting here on success.
    242266 * @param path Pathname of the binary to execute.
    243267 * @param ...  Command-line arguments.
     
    246270 *
    247271 */
    248 int task_spawnl(task_id_t *task_id, const char *path, ...)
     272int task_spawnl(task_id_t *task_id, task_wait_t *wait, const char *path, ...)
    249273{
    250274        /* Count the number of arguments. */
     
    262286       
    263287        va_start(ap, path);
    264         int rc = task_spawn(task_id, path, cnt, ap);
     288        int rc = task_spawn(task_id, wait, path, cnt, ap);
    265289        va_end(ap);
    266290       
     
    268292}
    269293
    270 int task_wait(task_id_t id, task_exit_t *texit, int *retval)
     294/** Setup waiting for a task.
     295 *
     296 * If the task finishes after this call succeeds, it is guaranteed that
     297 * task_wait(wait, &texit, &retval) will return correct return value for
     298 * the task.
     299 *
     300 * @param id   ID of the task to setup waiting for.
     301 * @param wait Information necessary for the later task_wait call is stored here.
     302 *
     303 * @return EOK on success, else error code.
     304 */
     305int task_setup_wait(task_id_t id, task_wait_t *wait)
     306{
     307        async_exch_t *exch = async_exchange_begin(session_ns);
     308        wait->aid = async_send_2(exch, NS_TASK_WAIT, LOWER32(id), UPPER32(id),
     309            &wait->result);
     310        async_exchange_end(exch);
     311
     312        return EOK;
     313}
     314
     315/** Cancel waiting for a task.
     316 *
     317 * This can be called *instead of* task_wait if the caller is not interested
     318 * in waiting for the task anymore.
     319 *
     320 * This function cannot be called if the task_wait was already called.
     321 *
     322 * @param wait task_wait_t previously initialized by task_setup_wait.
     323 */
     324void task_cancel_wait(task_wait_t *wait) {
     325        async_forget(wait->aid);
     326}
     327
     328/** Wait for a task to finish.
     329 *
     330 * This function returns correct values even if the task finished in
     331 * between task_setup_wait and this task_wait call.
     332 *
     333 * This function cannot be called more than once with the same task_wait_t
     334 * (it can be reused, but must be reinitialized with task_setup_wait first)
     335 *
     336 * @param wait   task_wait_t previously initialized by task_setup_wait.
     337 * @param texit  Store type of task exit here.
     338 * @param retval Store return value of the task here.
     339 *
     340 * @return EOK on success, else error code.
     341 */
     342int task_wait(task_wait_t *wait, task_exit_t *texit, int *retval)
    271343{
    272344        assert(texit);
    273345        assert(retval);
    274        
    275         async_exch_t *exch = async_exchange_begin(session_ns);
    276         sysarg_t te, rv;
    277         int rc = (int) async_req_2_2(exch, NS_TASK_WAIT, LOWER32(id),
    278             UPPER32(id), &te, &rv);
    279         async_exchange_end(exch);
    280        
    281         *texit = te;
    282         *retval = rv;
    283        
    284         return rc;
     346
     347        sysarg_t rc;
     348        async_wait_for(wait->aid, &rc);
     349
     350        if (rc == EOK) {
     351                *texit = IPC_GET_ARG1(wait->result);
     352                *retval = IPC_GET_ARG2(wait->result);
     353        }
     354
     355        return rc;
     356}
     357
     358/** Wait for a task to finish by its id.
     359 *
     360 * Note that this will fail with ENOENT if the task id is not registered in ns
     361 * (e.g. if the task finished). If you are spawning a task and need to wait
     362 * for its completion, use wait parameter of the task_spawn* functions instead
     363 * to prevent a race where the task exits before you may have a chance to wait
     364 * wait for it.
     365 *
     366 * @param id ID of the task to wait for.
     367 * @param texit  Store type of task exit here.
     368 * @param retval Store return value of the task here.
     369 *
     370 * @return EOK on success, else error code.
     371 */
     372int task_wait_task_id(task_id_t id, task_exit_t *texit, int *retval)
     373{
     374        task_wait_t wait;
     375        int rc = task_setup_wait(id, &wait);
     376        if (rc != EOK)
     377                return rc;
     378       
     379        return task_wait(&wait, texit, retval);
    285380}
    286381
  • uspace/lib/c/include/async.h

    rdf7f5cea r1c635d6  
    4545#include <atomic.h>
    4646#include <stdbool.h>
    47 #include <task.h>
     47#include <abi/proc/task.h>
    4848#include <abi/ddi/irq.h>
    4949#include <abi/ipc/event.h>
  • uspace/lib/c/include/ipc/common.h

    rdf7f5cea r1c635d6  
    3939#include <abi/ipc/ipc.h>
    4040#include <atomic.h>
    41 #include <task.h>
     41#include <abi/proc/task.h>
    4242
    4343#define IPC_FLAG_BLOCKING  0x01
  • uspace/lib/c/include/ipc/ipc.h

    rdf7f5cea r1c635d6  
    4444#include <abi/ipc/methods.h>
    4545#include <abi/synch.h>
    46 #include <task.h>
     46#include <abi/proc/task.h>
    4747
    4848typedef void (*ipc_async_callback_t)(void *, int, ipc_call_t *);
  • uspace/lib/c/include/loader/loader.h

    rdf7f5cea r1c635d6  
    3737#define LIBC_LOADER_H_
    3838
    39 #include <task.h>
     39#include <abi/proc/task.h>
    4040
    4141/** Forward declararion */
  • uspace/lib/c/include/task.h

    rdf7f5cea r1c635d6  
    3939#include <abi/proc/task.h>
    4040#include <stdarg.h>
     41#include <async.h>
     42#include <types/task.h>
    4143
    42 typedef enum {
    43         TASK_EXIT_NORMAL,
    44         TASK_EXIT_UNEXPECTED
    45 } task_exit_t;
     44typedef struct {
     45        ipc_call_t result;
     46        aid_t aid;
     47} task_wait_t;
     48
     49struct _TASK;
     50typedef struct _TASK task_t;
    4651
    4752extern task_id_t task_get_id(void);
     
    4954extern int task_kill(task_id_t);
    5055
    51 extern int task_spawnv(task_id_t *, const char *path, const char *const []);
    52 extern int task_spawnvf(task_id_t *, const char *path, const char *const [],
    53     int *const []);
    54 extern int task_spawn(task_id_t *, const char *path, int, va_list ap);
    55 extern int task_spawnl(task_id_t *, const char *path, ...);
     56extern int task_spawnv(task_id_t *, task_wait_t *, const char *path,
     57    const char *const []);
     58extern int task_spawnvf(task_id_t *, task_wait_t *, const char *path,
     59    const char *const [], int *const []);
     60extern int task_spawn(task_id_t *, task_wait_t *, const char *path, int,
     61    va_list ap);
     62extern int task_spawnl(task_id_t *, task_wait_t *, const char *path, ...);
    5663
    57 extern int task_wait(task_id_t id, task_exit_t *, int *);
     64extern int task_setup_wait(task_id_t, task_wait_t *);
     65extern void task_cancel_wait(task_wait_t *);
     66extern int task_wait(task_wait_t *, task_exit_t *, int *);
     67extern int task_wait_task_id(task_id_t, task_exit_t *, int *);
    5868extern int task_retval(int);
    5969
  • uspace/lib/gui/terminal.c

    rdf7f5cea r1c635d6  
    104104static void getterm(const char *svc, const char *app)
    105105{
    106         task_spawnl(NULL, APP_GETTERM, APP_GETTERM, svc, LOCFS_MOUNT_POINT,
    107             "--msg", "--wait", "--", app, NULL);
     106        task_spawnl(NULL, NULL, APP_GETTERM, APP_GETTERM, svc,
     107            LOCFS_MOUNT_POINT, "--msg", "--wait", "--", app, NULL);
    108108}
    109109
  • uspace/lib/hound/src/client.c

    rdf7f5cea r1c635d6  
    4242#include <stdio.h>
    4343#include <libarch/types.h>
     44#include <task.h>
    4445
    4546#include "protocol.h"
  • uspace/lib/posix/source/sys/wait.c

    rdf7f5cea r1c635d6  
    100100        int retval;
    101101       
    102         int rc = task_wait((task_id_t) pid, &texit, &retval);
     102        int rc = task_wait_task_id((task_id_t) pid, &texit, &retval);
    103103       
    104104        if (rc < 0) {
  • uspace/srv/audio/hound/main.c

    rdf7f5cea r1c635d6  
    4343#include <hound/server.h>
    4444#include <hound/protocol.h>
     45#include <task.h>
    4546
    4647#include "hound.h"
  • uspace/srv/bd/sata_bd/sata_bd.c

    rdf7f5cea r1c635d6  
    4545#include <loc.h>
    4646#include <macros.h>
     47#include <task.h>
    4748
    4849#include <ahci_iface.h>
  • uspace/srv/devman/driver.c

    rdf7f5cea r1c635d6  
    4040#include <str_error.h>
    4141#include <stdio.h>
     42#include <task.h>
    4243
    4344#include "dev.h"
     
    290291        log_msg(LOG_DEFAULT, LVL_DEBUG, "start_driver(drv=\"%s\")", drv->name);
    291292       
    292         rc = task_spawnl(NULL, drv->binary_path, drv->binary_path, NULL);
     293        rc = task_spawnl(NULL, NULL, drv->binary_path, drv->binary_path, NULL);
    293294        if (rc != EOK) {
    294295                log_msg(LOG_DEFAULT, LVL_ERROR, "Spawning driver `%s' (%s) failed: %s.",
  • uspace/srv/hid/isdv4_tablet/main.c

    rdf7f5cea r1c635d6  
    3636#include <ipc/mouseev.h>
    3737#include <inttypes.h>
     38#include <task.h>
    3839
    3940#include "isdv4.h"
  • uspace/srv/hid/remcons/remcons.c

    rdf7f5cea r1c635d6  
    226226       
    227227        task_id_t task;
    228         int rc = task_spawnl(&task, APP_GETTERM, APP_GETTERM, user->service_name,
     228        task_wait_t wait;
     229        int rc = task_spawnl(&task, &wait, APP_GETTERM, APP_GETTERM, user->service_name,
    229230            "/loc", "--msg", "--", APP_SHELL, NULL);
    230231        if (rc != EOK) {
     
    246247        task_exit_t task_exit;
    247248        int task_retval;
    248         task_wait(task, &task_exit, &task_retval);
     249        task_wait(&wait, &task_exit, &task_retval);
    249250        telnet_user_log(user, "%s terminated %s, exit code %d.", APP_GETTERM,
    250251            task_exit == TASK_EXIT_NORMAL ? "normally" : "unexpectedly",
  • uspace/srv/hid/rfb/main.c

    rdf7f5cea r1c635d6  
    3535#include <inttypes.h>
    3636#include <io/log.h>
     37#include <task.h>
    3738
    3839#include <abi/fb/visuals.h>
  • uspace/srv/net/ethip/ethip.c

    rdf7f5cea r1c635d6  
    4444#include <stdio.h>
    4545#include <stdlib.h>
     46#include <task.h>
    4647#include "arp.h"
    4748#include "ethip.h"
  • uspace/srv/net/inetsrv/inetsrv.c

    rdf7f5cea r1c635d6  
    4646#include <stdlib.h>
    4747#include <sys/types.h>
     48#include <task.h>
    4849#include "addrobj.h"
    4950#include "icmp.h"
  • uspace/srv/net/loopip/loopip.c

    rdf7f5cea r1c635d6  
    4444#include <stdio.h>
    4545#include <stdlib.h>
     46#include <task.h>
    4647
    4748#define NAME  "loopip"
  • uspace/srv/net/nconfsrv/nconfsrv.c

    rdf7f5cea r1c635d6  
    4848#include <stdlib.h>
    4949#include <sys/types.h>
     50#include <task.h>
    5051#include "iplink.h"
    5152#include "nconfsrv.h"
  • uspace/srv/net/slip/slip.c

    rdf7f5cea r1c635d6  
    4343#include <io/log.h>
    4444#include <errno.h>
     45#include <task.h>
    4546
    4647#define NAME            "slip"
  • uspace/srv/ns/ns.c

    rdf7f5cea r1c635d6  
    6666        while (true) {
    6767                process_pending_conn();
    68                 process_pending_wait();
    6968               
    7069                ipc_call_t call;
  • uspace/srv/ns/task.c

    rdf7f5cea r1c635d6  
    4040#include <macros.h>
    4141#include <malloc.h>
     42#include <types/task.h>
    4243#include "task.h"
    4344#include "ns.h"
    4445
    45 
    46 /* TODO:
    47  *
    48  * As there is currently no convention that each task has to be waited
    49  * for, the NS can leak memory because of the zombie tasks.
    50  *
    51  */
    5246
    5347/** Task hash table item. */
     
    195189                }
    196190               
    197                 hash_table_remove(&task_hash_table, &pr->id);
    198191                list_remove(&pr->link);
    199192                free(pr);
     
    204197void wait_for_task(task_id_t id, ipc_call_t *call, ipc_callid_t callid)
    205198{
    206         sysarg_t retval;
    207         task_exit_t texit;
    208         bool remove = false;
    209        
    210199        ht_link_t *link = hash_table_find(&task_hash_table, &id);
    211200        hashed_task_t *ht = (link != NULL) ?
     
    218207        }
    219208       
    220         if (!ht->finished) {
    221                 /* Add to pending list */
    222                 pending_wait_t *pr =
    223                     (pending_wait_t *) malloc(sizeof(pending_wait_t));
    224                 if (!pr) {
    225                         retval = ENOMEM;
    226                         goto out;
    227                 }
    228                
    229                 link_initialize(&pr->link);
    230                 pr->id = id;
    231                 pr->callid = callid;
    232                 list_append(&pr->link, &pending_wait);
     209        if (ht->finished) {
     210                task_exit_t texit = ht->have_rval ? TASK_EXIT_NORMAL :
     211                    TASK_EXIT_UNEXPECTED;
     212                ipc_answer_2(callid, EOK, texit, ht->retval);
    233213                return;
    234214        }
    235215       
    236         remove = true;
    237         retval = EOK;
    238        
    239 out:
    240         if (!(callid & IPC_CALLID_NOTIFICATION)) {
    241                 texit = ht->have_rval ? TASK_EXIT_NORMAL : TASK_EXIT_UNEXPECTED;
    242                 ipc_answer_2(callid, retval, texit, ht->retval);
    243         }
    244         if (remove)
    245                 hash_table_remove_item(&task_hash_table, link);
     216        /* Add to pending list */
     217        pending_wait_t *pr =
     218            (pending_wait_t *) malloc(sizeof(pending_wait_t));
     219        if (!pr) {
     220                if (!(callid & IPC_CALLID_NOTIFICATION))
     221                        ipc_answer_0(callid, ENOMEM);
     222                return;
     223        }
     224       
     225        link_initialize(&pr->link);
     226        pr->id = id;
     227        pr->callid = callid;
     228        list_append(&pr->link, &pending_wait);
    246229}
    247230
     
    314297        ht->retval = IPC_GET_ARG1(*call);
    315298       
     299        process_pending_wait();
     300       
    316301        return EOK;
    317302}
     
    336321        ht->finished = true;
    337322       
     323        process_pending_wait();
     324        hash_table_remove(&task_hash_table, &id);
     325       
    338326        return EOK;
    339327}
  • uspace/srv/ns/task.h

    rdf7f5cea r1c635d6  
    3535
    3636#include <ipc/common.h>
    37 #include <task.h>
     37#include <abi/proc/task.h>
    3838
    3939extern int task_init(void);
  • uspace/srv/taskmon/taskmon.c

    rdf7f5cea r1c635d6  
    8282
    8383                printf(NAME ": Executing %s -c %s -t %s\n", fname, dump_fname, s_taskid);
    84                 rc = task_spawnl(NULL, fname, fname, "-c", dump_fname, "-t", s_taskid,
     84                rc = task_spawnl(NULL, NULL, fname, fname, "-c", dump_fname, "-t", s_taskid,
    8585                    NULL);
    8686        } else {
    8787                printf(NAME ": Executing %s -t %s\n", fname, s_taskid);
    88                 rc = task_spawnl(NULL, fname, fname, "-t", s_taskid, NULL);
     88                rc = task_spawnl(NULL, NULL, fname, fname, "-t", s_taskid, NULL);
    8989        }
    9090
Note: See TracChangeset for help on using the changeset viewer.