Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proc::Async.kill doesn't seem to work when more than 1 proc is involved #6304

Closed
p6rt opened this issue Jun 2, 2017 · 4 comments
Closed
Labels

Comments

@p6rt
Copy link

p6rt commented Jun 2, 2017

Migrated from rt.perl.org#131479 (status was 'resolved')

Searchable as RT131479$

@p6rt
Copy link
Author

p6rt commented Jun 2, 2017

From @zoffixznet

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");
}

@p6rt
Copy link
Author

p6rt commented Jun 2, 2017

From @zoffixznet

FWIW, resolving this ticket will automatically resolve this roast Issue​: Raku/roast#158

@p6rt
Copy link
Author

p6rt commented Jun 2, 2017

From @zoffixznet

On Thu, 01 Jun 2017 18​:42​:03 -0700, cpan@​zoffix.com wrote​:

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");
}

Thank you for the report. This is now fixed.

Fix​: rakudo/rakudo@99421d4caa
Test​: Raku/roast@e484c9f27e

@p6rt
Copy link
Author

p6rt commented Jun 2, 2017

@zoffixznet - Status changed from 'new' to 'resolved'

@p6rt p6rt closed this as completed Jun 2, 2017
@p6rt p6rt added the ASYNC label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant