From 77629f34429c1bc65af797dac687fd47fc73df4b Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 16 Jan 2020 14:42:07 -0800 Subject: [PATCH] Make poll return errno::inval if there are no subscriptions. (#193) `poll` with no subscriptions is effectively an infinite hang. Since wasm has no signals, use cases which involve waking up a libc `pause` call, which is implemented in terms of a poll with no subscriptions, aren't applicable. So all `pause` can do is suspend the program until the host environment terminates it. One situation where that's useful is in debugging, as it's sometimes useful to be able to suspend a process in place so that it can be inspected by a debugger. However, that doesn't require a fully infinite suspend; a suspend with a long timeout is adequate. Making the no-subscriptions case an error can help catch cases where applications unintentionally enter infinite loops. --- phases/ephemeral/witx/wasi_ephemeral_poll.witx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/phases/ephemeral/witx/wasi_ephemeral_poll.witx b/phases/ephemeral/witx/wasi_ephemeral_poll.witx index 7dcdb53e..a30b96af 100644 --- a/phases/ephemeral/witx/wasi_ephemeral_poll.witx +++ b/phases/ephemeral/witx/wasi_ephemeral_poll.witx @@ -12,6 +12,8 @@ (import "memory" (memory)) ;;; Concurrently poll for the occurrence of a set of events. + ;;; + ;;; If `nsubscriptions` is 0, returns `errno::inval`. (@interface func (export "oneoff") ;;; The events to which to subscribe. (param $in (@witx const_pointer $subscription))