Close for channels, similar to go, but
the details differ because this is C.
Added two functions, chanclose and chanisclosed.
We also added an err field to the alt entry, which
does not need to be initialized.
Chanclose prevents further elements to be sent to the
channel c. After closing a channel, send and recv never
block. Send always returns -1. Recv returns -1 if the
channel is empty. Alt may choose a CHANSND or CHANRCV that
failed because the channel was closed. In this case, the
err field of the Alt entry points to an error string stating
that the channel was closed and the operation was completed
with failure. If all entries have been selected and failed
because they were closed, alt returns -1.
|