/trunk/uspace/app/bdsh/exec.c |
---|
113,6 → 113,7 |
{ |
task_id_t tid; |
char *tmp; |
int retval; |
tmp = str_dup(find_command(cmd)); |
free(found); |
125,6 → 126,9 |
return 1; |
} |
task_wait(tid); |
task_wait(tid, &retval); |
if (retval != 0) |
printf("Command failed (return value %d).\n", retval); |
return 0; |
} |
/trunk/uspace/app/getvc/getvc.c |
---|
73,6 → 73,8 |
int main(int argc, char *argv[]) |
{ |
int retval; |
if (argc < 3) { |
usage(); |
return -1; |
97,7 → 99,7 |
version_print(argv[1]); |
task_id_t id = spawn(argv[2]); |
task_wait(id); |
task_wait(id, &retval); |
return 0; |
} |
/trunk/uspace/lib/libc/include/task.h |
---|
42,8 → 42,10 |
extern task_id_t task_get_id(void); |
extern int task_set_name(const char *name); |
extern task_id_t task_spawn(const char *path, char *const argv[]); |
extern int task_wait(task_id_t id); |
extern int task_wait(task_id_t id, int *retval); |
extern int task_retval(int val); |
#endif |
/** @} |
/trunk/uspace/lib/libc/include/ipc/ns.h |
---|
39,7 → 39,8 |
typedef enum { |
NS_PING = IPC_FIRST_USER_METHOD, |
NS_TASK_WAIT |
NS_TASK_WAIT, |
NS_RETVAL |
} ns_request_t; |
#endif |
/trunk/uspace/lib/libc/generic/task.c |
---|
148,10 → 148,26 |
return 0; |
} |
int task_wait(task_id_t id) |
int task_wait(task_id_t id, int *retval) |
{ |
return (int) async_req_2_0(PHONE_NS, NS_TASK_WAIT, LOWER32(id), UPPER32(id)); |
ipcarg_t rv; |
int rc; |
rc = (int) async_req_2_1(PHONE_NS, NS_TASK_WAIT, LOWER32(id), |
UPPER32(id), &rv); |
*retval = rv; |
return rc; |
} |
int task_retval(int val) |
{ |
task_id_t id; |
id = task_get_id(); |
return (int) async_req_3_0(PHONE_NS, NS_RETVAL, LOWER32(id), |
UPPER32(id), val); |
} |
/** @} |
*/ |
/trunk/uspace/lib/libc/generic/libc.c |
---|
61,6 → 61,8 |
void __main(void *pcb_ptr) |
{ |
int retval; |
__heap_init(); |
__async_init(); |
fibril_t *fibril = fibril_setup(); |
82,8 → 84,10 |
__stdio_init(__pcb->filc, __pcb->filv); |
} |
main(argc, argv); |
retval = main(argc, argv); |
__stdio_done(); |
(void) task_retval(retval); |
} |
void __exit(void) |
/trunk/uspace/srv/ns/ns.c |
---|
170,6 → 170,9 |
MERGE_LOUP32(IPC_GET_ARG1(call), IPC_GET_ARG2(call)); |
wait_for_task(id, &call, callid); |
continue; |
case NS_RETVAL: |
retval = ns_task_retval(&call); |
break; |
default: |
retval = ENOENT; |
break; |
/trunk/uspace/srv/ns/task.c |
---|
63,6 → 63,7 |
typedef struct { |
link_t link; |
task_id_t id; /**< Task ID. */ |
int retval; |
bool destroyed; |
} hashed_task_t; |
173,7 → 174,7 |
continue; |
if (!(pr->callid & IPC_CALLID_NOTIFICATION)) |
ipc_answer_0(pr->callid, EOK); |
ipc_answer_1(pr->callid, EOK, ht->retval); |
hash_table_remove(&task_hash_table, keys, 2); |
list_remove(cur); |
221,6 → 222,7 |
link_initialize(&ht->link); |
ht->id = id; |
ht->destroyed = (et == TASK_CREATE) ? false : true; |
ht->retval = -1; |
hash_table_insert(&task_hash_table, keys, &ht->link); |
} else { |
hashed_task_t *ht = |
261,9 → 263,31 |
out: |
if (!(callid & IPC_CALLID_NOTIFICATION)) |
ipc_answer_0(callid, retval); |
ipc_answer_1(callid, retval, ht->retval); |
} |
int ns_task_retval(ipc_call_t *call) |
{ |
task_id_t id; |
unsigned long keys[2]; |
id = MERGE_LOUP32(IPC_GET_ARG1(*call), IPC_GET_ARG2(*call)); |
keys[0] = LOWER32(id); |
keys[1] = UPPER32(id); |
link_t *link = hash_table_find(&task_hash_table, keys); |
hashed_task_t *ht = (link != NULL) ? |
hash_table_get_instance(link, hashed_task_t, link) : NULL; |
if ((ht == NULL) || ht->destroyed) |
return EINVAL; |
ht->retval = IPC_GET_ARG3(*call); |
return EOK; |
} |
/** |
* @} |
*/ |
/trunk/uspace/srv/ns/task.h |
---|
42,6 → 42,8 |
extern void wait_notification(wait_type_t et, task_id_t id); |
extern void wait_for_task(task_id_t id, ipc_call_t *call, ipc_callid_t callid); |
extern int ns_task_retval(ipc_call_t *call); |
#endif |
/** |