Skip to content

Commit

Permalink
Make poll return errno::inval if there are no subscriptions. (#193)
Browse files Browse the repository at this point in the history
`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.
  • Loading branch information
sunfishcode committed Jan 16, 2020
1 parent da78736 commit 77629f3
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions phases/ephemeral/witx/wasi_ephemeral_poll.witx
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 77629f3

Please sign in to comment.