Skip to content

Commit 98ee440

Browse files
authored
Record that standard input is the handle zero, which one interface reserves (#17)
The streams this implementation hands out are the environment's own descriptors, which is what openkal.stream's transfer operations take and what makes a stream it hands out interchangeable with one it received. Standard input is therefore the handle zero, and kal_spawn_streams reserves zero to mean "the stream the parent has". The two readings agree at position `in` --- placing standard input at standard input and inheriting it are the same act --- and cannot be told apart anywhere else. openkal-musl found it while answering openkal-linux#13: classifying "this descriptor has no stream" by the handle's VALUE refused every spawn. Nothing changes. Packing these three would make a stream this implementation hands out different in kind from the descriptors kal_fs_stream and kal_process_channel report, and the interface has no operation that would unpack it for a caller. The specification records the collision (mcpplibs/openkal#18) and openkal-musl refuses the one spawn it makes inexpressible; what was missing was a reader of this file being able to see any of that.
1 parent baa5d93 commit 98ee440

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

src/stream.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,26 @@
33

44
extern "C" {
55

6+
// THE STREAMS ARE THIS ENVIRONMENT'S OWN DESCRIPTORS AND ARE NOT PACKED, which
7+
// is what `openkal.stream`'s transfer operations take and what makes a stream
8+
// this implementation hands out interchangeable with one it received.
9+
//
10+
// ⚠️⚠️ ONE CONSEQUENCE, AND IT IS NOT VISIBLE FROM THIS FILE. Standard input is
11+
// therefore the handle ZERO, and `kal_spawn_streams` reserves zero to mean
12+
// "the stream the parent has" (openkal/process.h). The two readings agree at
13+
// position `in` --- placing standard input at standard input and inheriting it
14+
// are the same act --- and cannot be told apart anywhere else, so a caller that
15+
// places its own standard input at position `out` is asking for something that
16+
// structure cannot express.
17+
//
18+
// The specification records the collision and what a caller should do about it;
19+
// openkal-musl refuses that spawn rather than passing on a word that would be
20+
// read as inheritance. An implementation MAY remove the ambiguity for every
21+
// caller by not answering any stream enquiry with zero, and this one does not:
22+
// packing these three would make a stream this implementation hands out
23+
// different in kind from the descriptors `kal_fs_stream` and
24+
// `kal_process_channel` report, and the interface has no operation that would
25+
// unpack it for the caller.
626
kal_stream kal_stdin (void) { return kal_stream{0}; }
727
kal_stream kal_stdout(void) { return kal_stream{1}; }
828
kal_stream kal_stderr(void) { return kal_stream{2}; }

0 commit comments

Comments
 (0)