-
Notifications
You must be signed in to change notification settings - Fork 30
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
Add packetry-cli
wrapper program
#154
Conversation
This is necessary on Windows, where we can't have the same binary serve as both a GUI and a console program, due to the constraints of the PE binary format. Instead, we add a new 'packetry-cli' console binary which simply acts as a wrapper around the main GUI binary. The wrapper sets the PACKETRY_ATTACH_CONSOLE environment variable, which tells the main process to attach to the wrapping parent's console. The wrapper waits for the child to complete, and mirrors its exit code.
Note: Cargo doesn't currently support platform-specific binary targets. So we have to build I think this is the right choice though, because it means that scripts and documentation can be written to always use |
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.
I think this is a great solution! I tested on Linux, macOS, and Windows, and everything worked except that I found a bug with --test-cynthion --save-captures
. On Windows I got:
Capture enabled, speed: High (480Mbps)
Starting read from test device
Read 4096 bytes from test device
Requesting capture stop
Capture disabled
thread 'main' panicked at src\test_cynthion.rs:28:64:
called `Result::unwrap()` on an `Err` value: The system cannot find the file specified. (os error 2)
On macOS I saw similar ("No such file or directory"). I retested on macOS with Packetry 0.1.0 from Homebrew, and --save-captures
worked. I haven't tested --save-captures
on Linux.
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.
I reproduced the bug on Linux and with the main branch, so it was not introduced with this PR. I'll open an issue.
This is necessary on Windows, where we can't have the same binary serve as both a GUI and a console program, due to the constraints of the PE binary format. See e.g. this post by Raymond Chen, and this StackOverflow discussion.
Instead, we add a new
packetry-cli
console binary which simply acts as a wrapper around the main GUI binary.The wrapper sets the
PACKETRY_ATTACH_CONSOLE
environment variable, which tells the main process to attach to the wrapping parent's console. The wrapper waits for the child to complete, and mirrors its exit code.Thanks to @pointy56 for investigating and prototyping this solution.