65
static pid_t pex_helenos_exec_child(struct pex_obj *obj ATTRIBUTE_UNUSED,
78
static pid_t pex_helenos_exec_child(struct pex_obj *obj,
66
79
int flags ATTRIBUTE_UNUSED,
67
80
const char *executable, char * const * argv,
68
81
char * const * env ATTRIBUTE_UNUSED,
76
89
files[2] = &errdes;
79
task_id_t task_id = 0;
92
struct pex_helenos *pex_helenos = (struct pex_helenos *) obj->sysdep;
94
/* Prepare space for the task_wait structure. */
95
pex_helenos->tasks = XRESIZEVEC(struct pex_task_wait,
96
pex_helenos->tasks, pex_helenos->task_count + 1);
99
struct pex_task_wait *this_task = &pex_helenos->tasks[pex_helenos->task_count];
101
char full_path[1024];
81
102
// FIXME: decide on paths
82
103
snprintf(full_path, 1023, "/app/%s", executable);
83
int rc = task_spawnvf(&task_id, full_path, argv, files);
104
int rc = task_spawnvf(&this_task->task_id, &this_task->task_wait,
105
full_path, argv, files);
87
109
*errmsg = "task_spawnvf";
110
pex_helenos->tasks = XRESIZEVEC(struct pex_task_wait,
111
pex_helenos->tasks, pex_helenos->task_count);
88
112
return (pid_t) -1;
91
return (pid_t) task_id;
115
pex_helenos->task_count++;
117
return (pid_t) this_task->task_id;
94
static int pex_helenos_wait(struct pex_obj *obj ATTRIBUTE_UNUSED,
120
static int pex_helenos_wait(struct pex_obj *obj,
95
121
pid_t pid, int *status,
96
122
struct pex_time *time, int done,
97
123
const char **errmsg, int *err)
125
struct pex_helenos *pex_helenos = (struct pex_helenos *) obj->sysdep;
126
task_id_t task_id = (task_id_t) pid;
128
/* Find the task in the list of known ones. */
129
struct pex_task_wait *this_task = NULL;
130
for (size_t i = 0; i < pex_helenos->task_count; i++) {
131
if (pex_helenos->tasks[i].task_id == task_id) {
132
this_task = &pex_helenos->tasks[i];
137
if (this_task == NULL) {
139
*errmsg = "no such task registered";
100
145
* If @c done is set, we are cleaning-up. Kill the process
104
task_kill( (task_id_t) pid);
149
task_kill(this_task->task_id);
107
152
if (time != NULL) {
147
203
struct pex_obj *pex_init(int flags, const char *pname, const char *tempbase)
149
return pex_init_common(flags, pname, tempbase, &funcs);
205
/* Common initialization. */
206
struct pex_obj *obj = pex_init_common(flags, pname, tempbase, &funcs);
208
/* Prepare the HelenOS specific data. */
209
struct pex_helenos *pex_helenos = XNEW(struct pex_helenos);
210
pex_helenos->tasks = NULL;
211
pex_helenos->task_count = 0;
213
obj->sysdep = pex_helenos;