Address some lifetime issues in the single-process case.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4565 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2023-10-21 19:47:47 +00:00
parent 15676e0f4f
commit 626fa4f27b
2 changed files with 43 additions and 23 deletions

View File

@ -67,6 +67,7 @@ static void _tf_taskstub_run_sandbox_thread(void* data)
{
uv_file fd = (uv_file)(intptr_t)data;
tf_task_t* task = tf_task_create();
tf_task_set_one_proc(task, true);
tf_task_configure_from_fd(task, fd);
/* The caller will trigger tf_task_activate with a message. */
tf_task_run(task);
@ -455,11 +456,18 @@ static JSValue _taskstub_execute(JSContext* context, JSValueConst this_val, int
static JSValue _taskstub_kill(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv)
{
tf_taskstub_t* stub = JS_GetOpaque(this_val, _classId);
JSValue result = JS_UNDEFINED;
if (!tf_task_get_one_proc(stub->_owner))
{
uv_process_kill(&stub->_process, SIGTERM);
}
return JS_UNDEFINED;
else
{
promiseid_t promise = -1;
result = tf_task_allocate_promise(stub->_owner, &promise);
tf_task_send_promise_message(stub->_owner, stub, kKill, promise, JS_UNDEFINED);
}
return result;
}
void tf_taskstub_destroy(tf_taskstub_t* stub)