Skip to content

Commit

Permalink
Handle a couple of Windows edge cases better (#1495)
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Corry authored Mar 17, 2023
1 parent 565ea39 commit 9847c95
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/event_sources/event_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ class WindowsEventThread: public Thread {
void recalculate_handles() {
int index = 1;
for (auto resource_event : resource_events_) {
if (index >= MAXIMUM_WAIT_OBJECTS) {
// Windows only allows 64 handles - we would have to move to a tree to
// support more.
FATAL("Too many events");
}
if (resource_event->is_event_enabled()) {
handles_[index] = resource_event->event();
resources_[index] = resource_event->resource();
Expand Down
10 changes: 10 additions & 0 deletions src/resources/pipe_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,16 @@ static Object* fork_helper(
if (GetFileType(startup_info.hStdError) == FILE_TYPE_PIPE && !is_inherited(err_object))
CloseHandle(startup_info.hStdError);

if (!process_information.hProcess) {
// We are running on Wine, and we have started a Linux executable,
// which means we can't track when it terminates. But we already
// started the process. We don't want to define yet another C++-thrown
// exception for this marginal case, so we throw one of the standard
// exceptions here, but also print a warning on stderr.
fprintf(stderr, "Error: Running a Linux executable from Wine is not supported: '%ls'\n", command_line);
INVALID_ARGUMENT;
}

auto subprocess = new (resource_allocation.keep_result()) SubprocessResource(resource_group, process_information.hProcess);
proxy->set_external_address(subprocess);

Expand Down

0 comments on commit 9847c95

Please sign in to comment.