Skip to content

Commit

Permalink
Make '!fd 123' work again.
Browse files Browse the repository at this point in the history
When rewriting cloudabi-run in C++, '!fd stdout' and '!fd stderr' were
implemented, but '!fd 123' was not.

Fixes: #7
  • Loading branch information
EdSchouten committed Dec 30, 2018
1 parent 455a784 commit ab2ad7a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/cloudabi-run/yaml_file_descriptor_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,16 @@ const argdata_t *YAMLFileDescriptorFactory::GetScalar(const YAML::Mark &mark,
} else if (value == "stderr") {
fd = STDERR_FILENO;
} else {
// TODO(ed): Implement!
throw YAML::ParserException(mark, "XXX!");
// File descriptor number.
std::string value_str(value);
std::size_t len;
try {
fd = std::stoi(value_str, &len);
} catch (std::exception &e) {
throw YAML::ParserException(mark, "Invalid file descriptor number");
}
if (len != value_str.size())
throw YAML::ParserException(mark, "Invalid file descriptor number");
}
return argdatas_.emplace_back(argdata_t::create_fd(fd)).get();
} else if (tag == "tag:nuxi.nl,2015:cloudabi/executable") {
Expand Down

0 comments on commit ab2ad7a

Please sign in to comment.