Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 3147 → Rev 3148

/branches/dynload/uspace/lib/libc/generic/task.c
1,5 → 1,6
/*
* Copyright (c) 2006 Jakub Jermar
* Copyright (c) 2008 Jiri Svoboda
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
34,7 → 35,9
 
#include <task.h>
#include <ipc/ipc.h>
#include <ipc/loader.h>
#include <libc.h>
#include <string.h>
#include <async.h>
#include <errno.h>
 
57,8 → 60,13
 
return phone_id;
}
#include <stdio.h>
#include <unistd.h>
 
/** Create a new task by running an executable from VFS.
*
* @param path pathname of the binary to execute
* @param argv command-line arguments
* @return ID of the newly created task or zero on error.
*/
task_id_t task_spawn(const char *path, const char *argv[])
{
int phone_id;
65,30 → 73,35
ipc_call_t answer;
aid_t req;
int rc;
 
/* Spawn a program loader */
phone_id = task_spawn_loader();
if (phone_id < 0) return 0;
printf("phone_id:%d\n", phone_id);
 
// getchar();
/*
* Say hello so that the loader knows the incoming connection's
* phone hash.
*/
rc = async_req_0_0(phone_id, LOADER_HELLO);
if (rc != EOK) return 0;
 
// req = async_send_0(phone_id, 1024, &answer);
/* Send program pathname */
req = async_send_0(phone_id, LOADER_SET_PATHNAME, &answer);
rc = ipc_data_write_start(phone_id, (void *)path, strlen(path));
printf("->%d\n", rc);
if (rc != EOK) {
// async_wait_for(req, NULL);
async_wait_for(req, NULL);
return 1;
}
// async_wait_for(req, &rc);
 
async_wait_for(req, &rc);
if (rc != EOK) return 0;
// rc = async_req_0_0(phone_id, 1025);
// printf("->%d\n", rc);
// if (rc != EOK) return 0;
 
// ipc_hangup(phone_id);
/* Request loader to start the program */
rc = async_req_0_0(phone_id, LOADER_RUN);
if (rc != EOK) return 0;
 
ipc_hangup(phone_id);
 
return 1;
}