-
Notifications
You must be signed in to change notification settings - Fork 439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Eagerly close tempfile to fix #1082 #1087
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -122,7 +122,7 @@ impl Tool { | |
.into(), | ||
})?; | ||
|
||
let tmp = | ||
let mut tmp = | ||
NamedTempfile::new(&out_dir, "detect_compiler_family.c").map_err(|err| Error { | ||
kind: ErrorKind::IOError, | ||
message: format!( | ||
|
@@ -134,6 +134,9 @@ impl Tool { | |
})?; | ||
tmp.file() | ||
.write_all(include_bytes!("detect_compiler_family.c"))?; | ||
// Close the file handle *now*, otherwise the compiler may fail to open it on Windows | ||
// (#1082). The file stays on disk and its path remains valid until `tmp` is dropped. | ||
tmp.close(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's also do a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That would call the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for investigating this, I'd like I don't think we need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
|
||
let stdout = run_output( | ||
Command::new(path).arg("-E").arg(tmp.path()), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's change this method, to
fn take_file() -> Option<File>
, so we don't need theclose()
method