# New Ticket Created by Zoffix Znet
# Please include the string: [perl #131479]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/Ticket/Display.html?id=131479 >
This appears to hang more often than not, despite printing "Killing" messages.
perl6 -e 'await ^2 .map: {start { with Proc::Async.new: $*EXECUTABLE, "-e",
"sleep" -> $p { Promise.in(2).then: {say "Killing"; $p.kill: SIGTERM}; await
$p.start } }}'
However, if we reduce it to just 1 Proc, then it appears to work without
issues, killing the spawned Proc every time:
perl6 -e 'await ^1 .map: {start { with Proc::Async.new: $*EXECUTABLE, "-e",
"sleep" -> $p { Promise.in(2).then: {say "Killing"; $p.kill: SIGTERM}; await
$p.start } }}'
This looks to be the code handling the kill op, but I don't know if it looks
wrong or not:
https://github.com/MoarVM/MoarVM/blob/dff6a4198f44d0b2793863cc56cc41679c36677f/src/io/procops.c#L1072-L1085
void MVM_proc_kill_async(MVMThreadContext *tc, MVMObject *handle_obj, MVMint64
signal) {
/* Ensure it's a handle for a process. */
if (REPR(handle_obj)->ID == MVM_REPR_ID_MVMOSHandle) {
MVMOSHandle *handle = (MVMOSHandle *)handle_obj;
if (handle->body.ops == &proc_op_table) {
/* It's fine; send the kill by cancelling the task. */
MVMIOAsyncProcessData *data = (MVMIOAsyncProcessData
*)handle->body.data;
data->signal = signal;
MVM_io_eventloop_cancel_work(tc, data->async_task, NULL, NULL);
return;
}
}
MVM_exception_throw_adhoc(tc, "killprocasync requires a process handle");
}